boost any questions and praise

Firstly. Thank you very much team Boost, it looks like it will be very useful and solve many of my coding problems. I can create an any boost::any a1; I can assign something to it a1 = string1; I can get it back out later std::cout<<any_cast<std::string>(a1); A boost any has a "type()" method. However this produced an error. std::cout<<any_cast<a1.type()>(a1);

AMDG Alan Tennant wrote:
Firstly. Thank you very much team Boost, it looks like it will be very useful and solve many of my coding problems.
I can create an any boost::any a1;
I can assign something to it a1 = string1;
I can get it back out later std::cout<<any_cast<std::string>(a1);
A boost any has a "type()" method.
However this produced an error.
std::cout<<any_cast<a1.type()>(a1);
Template parameters have to be types. The result of a1.type() is a std::type_info object. In Christ, Steven Watanabe

Thanks for the info. Can it be done (at all, at the moment, elegantly, practically, by turning a std::type_info into a type) ? On 30 January 2010 19:58, Steven Watanabe <watanabesj@gmail.com> wrote:
AMDG
Alan Tennant wrote:
Firstly. Thank you very much team Boost, it looks like it will be very useful and solve many of my coding problems.
I can create an any boost::any a1;
I can assign something to it a1 = string1;
I can get it back out later std::cout<<any_cast<std::string>(a1);
A boost any has a "type()" method.
However this produced an error.
std::cout<<any_cast<a1.type()>(a1);
Template parameters have to be types. The result of a1.type() is a std::type_info object.
In Christ, Steven Watanabe
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

see attached Peter "Alan Tennant" <alan2here@gmail.com> wrote in message news:a557f5fb1001301059h1dfc32davd917a47d8c598a05@mail.gmail.com... Firstly. Thank you very much team Boost, it looks like it will be very useful and solve many of my coding problems. I can create an any boost::any a1; I can assign something to it a1 = string1; I can get it back out later std::cout<<any_cast<std::string>(a1); A boost any has a "type()" method. However this produced an error. std::cout<<any_cast<a1.type()>(a1); ------------------------------------------------------------------------------ _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Thanks :¬) I can't test it until tomorrow but it looks great. This appears to take boost::any closer to boost::variant. << support is most useful. I presume they still cast back to the original object in the same way that boost::any does and any non standard object they contain that will work in a stream will now work inside the boost::any. Is this going to be an official update or just a branch for me. Can I get a mention for inspiring the idea? Whats the empty struct for in main? Thanks for the info about Variant being faster. Especially with this new change it looks as if boost::any and boost::variant can be interchanged quite easily. On 1 February 2010 21:10, Peter Foelsche <foelsche@sbcglobal.net> wrote:
see attached
Peter
"Alan Tennant" <alan2here@gmail.com> wrote in message news:a557f5fb1001301059h1dfc32davd917a47d8c598a05@mail.gmail.com... Firstly. Thank you very much team Boost, it looks like it will be very useful and solve many of my coding problems.
I can create an any boost::any a1;
I can assign something to it a1 = string1;
I can get it back out later std::cout<<any_cast<std::string>(a1);
A boost any has a "type()" method.
However this produced an error.
std::cout<<any_cast<a1.type()>(a1);
------------------------------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

2010/2/2 Alan Tennant <alan2here@gmail.com>
<< support is most useful. I presume they still cast back to the original object in the same way that boost::any does and any non standard object they contain that will work in a stream will now work inside the boost::any.
Adobe poly <http://stlab.adobe.com/group__poly__related.html> library might be better for your use case. It's like boost::any with ability to add additional operators (e.g. operator<<). Roman Perepelitsa.

"Alan Tennant" <alan2here@gmail.com> wrote in message news:a557f5fb1002011639i142be9a0j29205e3ae643a6a9@mail.gmail.com... Thanks :¼)
I can't test it until tomorrow but it looks great. This appears to take boost::any closer to boost::variant.
<< support is most useful. I presume they still cast back to the original object in the same way that boost::any does and any non standard object they contain that will work in a stream will now work inside the boost::any.
Is this going to be an official update or just a branch for me.
I'm still unclear how to work with the people from boost. Usually I'm posting something here and hope for an answer.
Can I get a mention for inspiring the idea?
Whats the empty struct for in main?
just for testing what happens if some class does not provide the << operator. Peter
Thanks for the info about Variant being faster. Especially with this new change it looks as if boost::any and boost::variant can be interchanged quite easily.
On 1 February 2010 21:10, Peter Foelsche <foelsche@sbcglobal.net> wrote:
see attached
Peter "Alan Tennant" <alan2here@gmail.com> wrote in message news:a557f5fb1001301059h1dfc32davd917a47d8c598a05@mail.gmail.com... Firstly. Thank you very much team Boost, it looks like it will be very useful and solve many of my coding problems.
I can create an any boost::any a1;
I can assign something to it a1 = string1;
I can get it back out later std::cout<<any_cast<std::string>(a1);
A boost any has a "type()" method.
However this produced an error.
std::cout<<any_cast<a1.type()>(a1);
------------------------------------------------------------------------ --------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
------------------------------------------------------------------------ --------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (4)
-
Alan Tennant
-
Peter Foelsche
-
Roman Perepelitsa
-
Steven Watanabe