problem about boost-any-Collection of common programming errors


  • FrozenHeart
    c++ boost boost-spirit boost-spirit-qi boost-any
    I have the following code:#include <boost/any.hpp> #include <boost/spirit/include/qi.hpp>#include <iostream> #include <string>template <typename Iterator> struct parser : boost::spirit::qi::grammar<Iterator, boost::any, boost::spirit::qi::ascii::space_type> {parser() : parser::base_type(start){start %= boost::spirit::qi::int_;}boost::spirit::qi::rule<Iterator, boost::any, boost::spirit::qi::ascii::space_type> start; };int main() {const std::string input_

  • Maxpm
    c++ oop derived-class boost-any
    I’m making a simple boost::any-like class for educational purposes, but I can’t figure out how to access the stored value. I can set the value perfectly, but when I try to access any member in the “holder” class the compiler just complains that the member wasn’t found in the class it was derived from. I can’t declare the members as virtual because of the templates.Here’s the relevant code:class Element {struct ValueStorageBase{};template <typename Datatype>struct ValueStorage: public Val

  • KennyTM
    c++ templates metaprogramming boost-any
    Suppose I have a list of type list<boost::any> that has some type in it that is unknown. Now suppose I want to apply some operation to the elements in the list that is polymorphic. In this case, consider the + operator. Suppose that I know that the list will always contain a homogenous set of objects that support operator+, and I want to get the result of applying operator+ (the “sum” in one sense) between each element of the list into a new boost::any. Something like this:boost::any sum(l

  • lizarisk
    c++ boost casting boost-any
    I’d like to use boost::any as a universal type to store in a container and to pass to different functions. But inside these functions I always know the real type, so in runtime I don’t need any type safety checks and the imposed overhead, static_cast is enough.The ideal solution would be to use something like boost::polymorphic_downcast, but as I can see it can’t be applied in this case.Should I just write my own wrapper for void* or is there another option?

Web site is in building