|
Boost Users : |
From: Jaakko Jarvi (jajarvi_at_[hidden])
Date: 2002-09-13 13:21:40
> So if I explicitly list the template parameters, does it work? Hmmm...
>
> No, this doesn't work:
>
> for_each(ell.begin(), ell.end(),
> cout << _1 << endl<char, char_traits<char> >);
>
> I was hopeful --- I'm pretty sure I have the syntax right. I'm simply
> curious now: is it possible to make this work?
Explicit specialization should work, just tested under gcc3.2.
Here's another option, a helper function manip
that takes a stream and a manipulator and chooses the appropriate
instantiation of the endl template. Much nicer to just give the stream
object rather than the stream template args:
#include "boost/lambda/lambda.hpp"
#include <iostream>
namespace boost {
namespace lambda {
template <class CharT, class Traits>
inline
std::basic_ostream<CharT, Traits>&
(*manip(std::basic_ostream<CharT, Traits> &,
std::basic_ostream<CharT, Traits> &(*m)
(std::basic_ostream<CharT, Traits> &)))
(std::basic_ostream<CharT, Traits> &)
{
return m;
}
}
}
int main () {
using namespace std;
using namespace boost::lambda;
(cout << _1 << manip(cout, endl) << "Work!\n")("Seems to");
return 0;
}
Cheers, Jaakko
>
> Ken
> --
> Ken Yarnall
> Dept. of Mathematical Sciences Lebanon Valley College
> Assoc. Professor of Math and CS (717)867-6085 yarnall_at_[hidden]
>
>
>
> Yahoo! Groups Sponsor
> ADVERTISEMENT
> [d_300x250_071_4for49_1.gif]
>
> Info: <http://www.boost.org>
> Wiki: <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl>
> Unsubscribe: <mailto:boost-users-unsubscribe_at_[hidden]>
>
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>
-- -- -- Jaakko Järvi email: jajarvi_at_[hidden] -- Post Doctoral Fellow phone: +1 (812) 855-3608 -- Pervasive Technology Labs fax: +1 (812) 855-4829 -- Indiana University, Bloomington
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