|
Boost Users : |
From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2005-03-02 23:29:22
> > If the type is declared by a typedef:
> >
> > typedef foo::C C2;
> >
> > you can define the operator<< in the 'foo' namespace, and that should
> > work.
>
> That is very unfortunate. Is there no way to have the operator<< lookup
> occur in the scope of the call to BOOST_CHECK_EQUAL, by moving the
> wrap_stringstream logic and the call to operator<< into the macro itself ?
No. there are several reasons why it couldn't be done:
1. Printing log value in the scope of call would cause multiple value
evaluation. Imagine what if I write BOOST_CHECK_EQUAL( i++, 2 );
2. I need extra level of indirection to be able to prevent value from being
printed (BOOST_TEST_DONT_PRINT_LOG_VALUE(type))
3. I need extra level of indirection to be able to do custom printing for
some types
You have several choices
1. You could define operator<< in namespace foo
2. You could use BOOST_TEST_DONT_PRINT_LOG_VALUE(your type) on global scope
to prevent values of this type being printed at all
3. You could write struct C2 : foo::C {}; And unless you use non-default
constructor it will work.
Gennadiy
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net