Boost logo

Boost Users :

Subject: [Boost-users] Problem transforming a vector<bool> to a vector<any>
From: Fabrice_CBA (fabrice.lecuyer_at_[hidden])
Date: 2009-02-03 21:02:34


Hi everyone,

I am working on a project in which I'm using a "simplified" version of the
boost::any library. By simplified, I mean that I got rid of the #defines and
made it independent from the rest of boost. The changes are very small, and
in my opinion shouldn't impact much the class, since the general structure
is still there. My implementation is attached to this message.
http://www.nabble.com/file/p21822878/Any.h Any.h

However I am having a problem transferring a vector<bool> into a
vector<any>. It works for any other types I've tested, only booleans fail.
Here is an example:

                std::vector<std::string> source0(1, "SomeString");
                std::vector<long> source1(1, 666);
                std::vector<bool> source2(1, true);
                std::vector<double> source3(1, 6.66);

                std::vector<any> destination;
                destination.push_back(source0[0]);
                destination.push_back(source1[0]);
                destination.push_back(source2[0]);
                destination.push_back(source3[0]);

When checking what is in destination[2], it seems it only holds {...}, and
not the original {true}. Whereas it works perfectly for the other values.

Any idea on what I'm doing wrong? Any help appreciated.

Thanks,
Fabrice

-- 
View this message in context: http://www.nabble.com/Problem-transforming-a-vector%3Cbool%3E-to-a-vector%3Cany%3E-tp21822878p21822878.html
Sent from the Boost - Users mailing list archive at Nabble.com.

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