|
Boost : |
From: Paul A. Bristow (boost_at_[hidden])
Date: 2003-10-02 05:37:06
Silly me! It helps to put the manipulator first!
BOOST_MESSAGE("i = "<< makeManip(flog)(hex) << i );
Question on setw is still relevant.
Paul
| -----Original Message-----
| From: boost-bounces_at_[hidden]
| [mailto:boost-bounces_at_[hidden]]On Behalf Of Paul A. Bristow
| Sent: Thursday, October 02, 2003 11:22 AM
| To: Boost mailing list
| Subject: RE: [boost] Boost Test tools to test manipulators like
| hex,setw(15)...
|
|
| Gulp! The C++ manipulator interface is IMO done all complicated!
|
| I've tried this thus:
|
| int i = 15;
|
| unit_test_log::instance().set_log_stream(flog); // Switch to log file.
|
| BOOST_MESSAGE("Uncertain Class tests" << __FILE__ << ' ' << __TIMESTAMP__ );
| BOOST_MESSAGE("message" );
| BOOST_MESSAGE("i = " << i << makeManip(flog)(hex) ); // NB only one MACRO
| parameter
|
| which outputs to file flog
|
| Uncertain Class tests.\unc_tests.cpp Thu Oct 2 11:10:23 2003
| message
| i = 15
|
| rather than the i = f expected.
|
| And also I also wanted to use setw(int) and setprecision(int). Is
| similar code
| these in FC++?
|
| But thanks anyway - I am sure this is solvable somehow.
|
| Paul
|
|
| | -----Original Message-----
| | From: boost-bounces_at_[hidden]
| | [mailto:boost-bounces_at_[hidden]]On Behalf Of Brian McNamara
| | Sent: Wednesday, October 01, 2003 10:20 PM
| | To: Boost mailing list
| | Subject: Re: [boost] Boost Test tools to test manipulators like hex,
| | setw(15)...
| |
| |
| | On Wed, Oct 01, 2003 at 09:19:13PM +0100, Paul A. Bristow wrote:
| | > I have some fancy manipulators that I want to test carefully.
| | >
| | > Simply to show the problem, imagine I would like to be able to test
| | the effect
| | > of the std::ios::hex and setw() manipulators.
| | >
| | > I have tried this (but without much expectation as
| | > BOOST_MESSAGE("message", i << hex); doesn't work (Gennady said he
| | > might make it in future)
| | ...
| | > Suggestions - please.
| |
| | The C++ manipulator interface is IMO (and in hindsight) done all wrong.
| | Here is what I have done to make it work in FC++:
| |
| | ----------------------------------------------------------------------
| | // makeManip(aStream)(aManip) returns the manipulator for that stream
| | // e.g. makeManip(cout)(endl)
| | template <class C, class T>
| | struct ManipMaker {
| | std::basic_ostream<C,T>& (*
| | operator()( std::basic_ostream<C,T>& (*pfn)( std::basic_ostream<C,T>&) )
| | const )( std::basic_ostream<C,T>& ) { return pfn; }
| | std::basic_ios<C,T>& (*
| | operator()( std::basic_ios<C,T>& (*pfn)( std::basic_ios<C,T>& ) )
| | const )( std::basic_ios<C,T>& ) { return pfn; }
| | std::ios_base& (*
| | operator()( std::ios_base& (*pfn)( std::ios_base& ) )
| | const )( std::ios_base& ) { return pfn; }
| | };
| | template <class C, class T>
| | ManipMaker<C,T> makeManip( std::basic_ios<C,T>& )
| | { return ManipMaker<C,T>(); }
| | ----------------------------------------------------------------------
| |
| | I expect that even if
| |
| | BOOST_MESSAGE("message", i << hex);
| |
| | doesn't work, you will find that
| |
| | BOOST_MESSAGE("message", i << makeManip(cerr)(hex) );
| |
| | does (assuming that BOOST_MESSAGE goes to "cerr").
| |
| | --
| | -Brian McNamara (lorgon_at_[hidden])
| | _______________________________________________
| | Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost
|
|
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk