|
Boost : |
Subject: Re: [boost] [log] Release candidate 1
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2013-03-11 12:16:52
On Mon, Mar 11, 2013 at 8:03 PM, Klaim - Joël Lamotte <mjklaim_at_[hidden]> wrote:
> On Mon, Mar 11, 2013 at 4:19 PM, Andrey Semashev <andrey.semashev_at_[hidden]>
> wrote:
>
>> Could you send me a complete compilable code sample?
>
>
> Yes, I just tried with the following code which is not as minimal as it
> could be (it the headers includes a lot other headers) but it generate the
> same error in an empty project (generated with CMake) Note that I upgraded
> to Boost Log V2 in the same time than Boost from v1.52 to v1.53. The
> problem seem related to Phoenix as stream is just a typedef if I understand
> the code correctly. I added the compilation error log in case the problem
> comes from something I've setup: http://pastebin.com/zHRwaBsQ
>
> ------
>
> #include <boost/log/expressions/formatters.hpp>
> #include <boost/log/expressions/formatters/stream.hpp>
> #include <boost/log/sinks.hpp>
>
> namespace logattr
> {
> const auto MODULE_NAME = "ModuleName";
> const auto TIMESTAMP = "TimeStamp";
> }
>
> int main()
> {
>
> namespace blog = boost::log;
> namespace expr = blog::expressions;
>
> const auto FORMAT_MODULE_NAME = expr::attr< std::string >(
> logattr::MODULE_NAME );
> const auto FORMAT_TIMESTAMP =
> expr::format_date_time<boost::posix_time::ptime>( logattr::TIMESTAMP,
> "%Y-%m-%d %H:%M:%S" );
> const auto FORMAT_MESSAGE = expr::message;
>
> const auto a = expr::stream << FORMAT_TIMESTAMP; // compiles
> const auto c = expr::stream << FORMAT_MODULE_NAME; // compiles
> const auto d = expr::stream << FORMAT_MESSAGE; // error: no operator "<<"
> matches these operand
> const auto e = expr::stream << "test"; // error: no operator "<<" matches
> these operand
> const auto f = expr::stream << std::string("test"); // error: no operator
> "<<" matches these operand
>
>
> return 0;
> }
You also have to #include <boost/phoenix/operators.hpp> as
Boost.Phoenix does not include its operator overloads by default. Or
simply #include <boost/log/expressions.hpp> which takes care of that.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk