|
Boost : |
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2007-07-13 10:51:24
Jarrad,
> Thanks, I saw this a long time ago at codeproject also. Is
> there any real hope in the future that boost::any will take
> advantage of this implementation?
Only, if somebody cares to push it through the review process (writes
documentation, etc.). Currently it's just an internal implementation detail
in Spirit2.
> This is related to my original question. While using
> hold_any, I run into this problem when trying to use
> BOOST_SPIRIT_DEBUG with a vector of hold_any.
>
> binary '>>' : no operator found which takes a right-hand
> operand of type 'std::vector<_Ty>' (or there is no acceptable
> conversion)
> 1> with
> 1> [
> 1> _Ty=boost::spirit::hold_any
> 1> ]
>
> The code I added was as follows
>
> std::istream& operator>> (std::istream& i, vector<hold_any>& obj) {
> return i;//obj.table->stream_in(i, &obj.object); }
>
> std::ostream& operator<< (std::ostream& o, vector<hold_any>
> const& obj) {
> o << "[";
> for(size_t i = 0; i < obj.size(); i++)
> {
> if(i > 0)
> o << ",";
> o << obj[i];
> }
> o << "]";
> return o;
> }
Seems to be fine this way. Hold_any supports streaming only if the contained
datatype is streamable.
Regards Hartmut
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk