
Sérgio Vale e Pace wrote:
Jonathan Turkanis wrote:
Sérgio Pace wrote:
great I was looking for some way of doing that. template metaprogramming rules!
It's not really template metaprogramming ... but I'm not really sure what to call it. I guess "Modern C++ Design" :-)
If I understood correctly you create a last choice overloaded operator<< that return tag and verify if check gets an ostrem or a tag is that correct?
I'd do it like this: #include < .... is_default_intertable.hpp> #include <boost/mpl/bool.hpp> template<typename ValueType> class holder : public placeholder { virtual void print(std::ostream& out) const { return print(out, is_default_insertable<ValueType>()); } void print(std::ostream& out, mpl::true_) { out<<held; } void print(std::ostream& out, mpl::false_) { // handle non-streamable types. For instance: out<< "boost::any[" << typeid(ValueType).name() << "]"; }
2. You should probably support narrow and wide streams.
good idea
I'm about to post an announcement for an interface library which can be thought of as a generalization of Boost.Any. Very roughly, while an instance of boost::any can be bound to any object (actually any instance of a value type), an interface reference can be bound to any object of a type which (non-intrusively) implements the interface. Although I haven't implemented operator overloading yet, use will be as follows:
I am following the "BIL" discussion for a while now, and IŽm looking forward to put my hands on it
Thanks. I'm surprised how many people have heard of it before I announced it here. Jonathan