AMDG Fabrice_CBA wrote:
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::vectorstd::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.
vector<bool> strikes again... The problem is that for vector<bool> (only) source2[0] is not of type bool. You need to cast. In Christ, Steven Watanabe