Search Results

Search found 6850 results on 274 pages for 'boost random'.

Page 1/274 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Problem with boost::find_format_all, boost::regex_finder and custom regex formatter (bug boost 1.42)

    - by Nikko
    I have a code that has been working for almost 4 years (since boost 1.33) and today I went from boost 1.36 to boost 1.42 and now I have a problem. I'm calling a custom formatter on a string to format parts of the string that match a REGEX. For instance, a string like: "abc;def:" will be changed to "abc\2Cdef\3B" if the REGEX contains "([;:])" boost::find_format_all( mystring, boost::regex_finder( REGEX ), custom_formatter() ); The custom formatter looks like this: struct custom_formatter() { template< typename T > std::string operator()( const T & s ) const { std::string matchStr = s.match_results().str(1); // perform substitutions return matchStr; } } This worked fine but with boost 1.42 I know have "non initialized" s.match_results() which yield to boost::exception_detail::clone_implINS0_::error_info_injectorISt11logic_errorEEEE - Attempt to access an uninitialzed boost::match_results< class. This means that sometimes I am in the functor to format a string but there is no match. Am I doing something wrong? Or is it normal to enter the functor when there is no match and I should check against something? for now my solution is to try{}catch(){} the exception and everything works fine, but somehow that doesn't feel very good. EDIT1 Actually I have a new empty match at the end of each string to parse. EDIT2 : one solution inspired by ablaeul template< typename T > std::string operator()( const T & s ) const { if( s.begin() == s.end() ) return std::string(); std::string matchStr = s.match_results().str(1); // perform substitutions return matchStr; } *EDIT3 Seems to be a bug in (at least) boost 1.42 *

    Read the article

  • build error with boost spirit grammar (boost 1.43 and g++ 4.4.1)

    - by lurscher
    I'm having issues getting a small spirit/qi grammar to compile. The build stack trace is fugly enought to not make any sense to me (despite some assertion_failed i could notice in there but that didn't brought much information) the input grammar header: inputGrammar.h #include <boost/config/warning_disable.hpp> #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/phoenix_core.hpp> #include <boost/spirit/include/phoenix_operator.hpp> #include <boost/spirit/include/phoenix_fusion.hpp> #include <boost/spirit/include/phoenix_stl.hpp> #include <boost/fusion/include/adapt_struct.hpp> #include <boost/variant/recursive_variant.hpp> #include <boost/foreach.hpp> #include <iostream> #include <fstream> #include <string> #include <vector> namespace sp = boost::spirit; namespace qi = boost::spirit::qi; using namespace boost::spirit::ascii; //using namespace boost::spirit::arg_names; namespace fusion = boost::fusion; namespace phoenix = boost::phoenix; using phoenix::at_c; using phoenix::push_back; template< typename Iterator , typename ExpressionAST > struct InputGrammar : qi::grammar<Iterator, ExpressionAST(), space_type> { InputGrammar() : InputGrammar::base_type( block ) { tag = sp::lexeme[+(alpha) [sp::_val += sp::_1]];//[+(char_ - '<') [_val += _1]]; block = sp::lit("block") [ at_c<0>(sp::_val) = sp::_1] >> "(" >> *instruction[ push_back( at_c<1>(sp::_val) , sp::_1 ) ] >> ")"; command = tag [ at_c<0>(sp::_val) = sp::_1] >> "(" >> *instruction [ push_back( at_c<1>(sp::_val) , sp::_1 )] >> ")"; instruction = ( command | tag ) [sp::_val = sp::_1]; } qi::rule< Iterator , std::string() , space_type > tag; qi::rule< Iterator , ExpressionAST() , space_type > block; qi::rule< Iterator , ExpressionAST() , space_type > function_def; qi::rule< Iterator , ExpressionAST() , space_type > command; qi::rule< Iterator , ExpressionAST() , space_type > instruction; }; the test build program: i seems the build fails at qi::phrase_parse, i am using boost 1.43 and g++ 4.4.1 #include <iostream> #include <string> #include <vector> using namespace std; //my grammar #include <InputGrammar.h> struct MockExpressionNode { std::string name; std::vector< MockExpressionNode > operands; typedef std::vector< MockExpressionNode >::iterator iterator; typedef std::vector< MockExpressionNode >::const_iterator const_iterator; iterator begin() { return operands.begin(); } const_iterator begin() const { return operands.begin(); } iterator end() { return operands.end(); } const_iterator end() const { return operands.end(); } bool is_leaf() const { return ( operands.begin() == operands.end() ); } }; BOOST_FUSION_ADAPT_STRUCT( MockExpressionNode, (std::string, name) (std::vector<MockExpressionNode>, operands) ) int const tabsize = 4; void tab(int indent) { for (int i = 0; i < indent; ++i) std::cout << ' '; } template< typename ExpressionNode > struct ExpressionNodePrinter { ExpressionNodePrinter(int indent = 0) : indent(indent) { } void operator()(ExpressionNode const& node) const { cout << " tag: " << node.name << endl; for (int i=0 ; i < node.operands.size() ; i++ ) { tab( indent ); cout << " arg "<<i<<": "; ExpressionNodePrinter(indent + 2)( node.operands[i]); cout << endl; } } int indent; }; int test() { MockExpressionNode root; InputGrammar< string::const_iterator , MockExpressionNode > g(); std::string litA = "litA"; std::string litB = "litB"; std::string litC = "litC"; std::string litD = "litD"; std::string litE = "litE"; std::string litF = "litF"; std::string source = litA+"( "+litB+" ,"+litC+" , "+ litD+" ( "+litE+", "+litF+" ) "+ " )"; string::const_iterator iter = source.begin(); string::const_iterator end = source.end(); bool r = qi::phrase_parse( iter , end , g , root , space ); ExpressionNodePrinter< MockExpressionNode > np; np( root ); }; int main() { test(); } finally, the build error is the following: /usr/bin/make -f nbproject/Makefile-linux_amd64_devel.mk SUBPROJECTS= .build-conf make[1]: se ingresa al directorio `/home/mineq/NetBeansProjects/InputParserTests' /usr/bin/make -f nbproject/Makefile-linux_amd64_devel.mk dist/linux_amd64_devel/GNU-Linux-x86/vpuinputparsertests make[2]: se ingresa al directorio `/home/mineq/NetBeansProjects/InputParserTests' mkdir -p build/linux_amd64_devel/GNU-Linux-x86 rm -f build/linux_amd64_devel/GNU-Linux-x86/tests_main.o.d g++ `llvm-config --cxxflags` `pkg-config --cflags unittest-cpp` `pkg-config --cflags boost-1.43` `pkg-config --cflags boost-coroutines` -c -g -I../InputParser -MMD -MP -MF build/linux_amd64_devel/GNU-Linux-x86/tests_main.o.d -o build/linux_amd64_devel/GNU-Linux-x86/tests_main.o tests_main.cpp from /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/auto.hpp:16, from /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi.hpp:15, from /home/mineq/third_party/boost_1_43_0/boost/spirit/include/qi.hpp:16, from ../InputParser/InputGrammar.h:12, from tests_main.cpp:14: /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/parse.hpp: In function ‘bool boost::spirit::qi::phrase_parse(Iterator&, Iterator, const Expr&, const Skipper&, boost::spirit::qi::skip_flag::enum_type, Attr&) [with Iterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Expr = InputGrammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MockExpressionNode>(), Skipper = MockExpressionNode, Attr = const boost::proto::exprns_::expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, 0l>]’: In file included from /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/detail/parse_auto.hpp:14, /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/parse.hpp:125: instantiated from ‘bool boost::spirit::qi::phrase_parse(Iterator&, Iterator, const Expr&, const Skipper&, Attr&) [with Iterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Expr = InputGrammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MockExpressionNode>(), Skipper = MockExpressionNode, Attr = const boost::spirit::ascii::space_type]’ tests_main.cpp:206: instantiated from here /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/parse.hpp:99: error: no matching function for call to ‘assertion_failed(mpl_::failed************ (boost::spirit::qi::phrase_parse(Iterator&, Iterator, const Expr&, const Skipper&, boost::spirit::qi::skip_flag::enum_type, Attr&) [with Iterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Expr = InputGrammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MockExpressionNode>(), Skipper = MockExpressionNode, Attr = const boost::proto::exprns_::expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, 0l>]::error_invalid_expression::************)(InputGrammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MockExpressionNode> (*)()))’ /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/parse.hpp:125: instantiated from ‘bool boost::spirit::qi::phrase_parse(Iterator&, Iterator, const Expr&, const Skipper&, Attr&) [with Iterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Expr = InputGrammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MockExpressionNode>(), Skipper = MockExpressionNode, Attr = const boost::spirit::ascii::space_type]’ tests_main.cpp:206: instantiated from here /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/parse.hpp:100: error: no matching function for call to ‘assertion_failed(mpl_::failed************ (boost::spirit::qi::phrase_parse(Iterator&, Iterator, const Expr&, const Skipper&, boost::spirit::qi::skip_flag::enum_type, Attr&) [with Iterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Expr = InputGrammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MockExpressionNode>(), Skipper = MockExpressionNode, Attr = const boost::proto::exprns_::expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, 0l>]::error_invalid_expression::************)(MockExpressionNode))’ from /home/mineq/third_party/boost_1_43_0/boost/proto/proto.hpp:12, from /home/mineq/third_party/boost_1_43_0/boost/spirit/home/support/meta_compiler.hpp:17, from /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/meta_compiler.hpp:14, from /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/action/action.hpp:14, from /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/action.hpp:14, from /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi.hpp:14, from /home/mineq/third_party/boost_1_43_0/boost/spirit/include/qi.hpp:16, from ../InputParser/InputGrammar.h:12, from tests_main.cpp:14: /home/mineq/third_party/boost_1_43_0/boost/proto/detail/expr0.hpp: At global scope: /home/mineq/third_party/boost_1_43_0/boost/proto/proto_fwd.hpp: In instantiation of ‘boost::proto::exprns_::expr<boost::proto::tag::terminal, boost::proto::argsns_::term<InputGrammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MockExpressionNode>()>, 0l>’: In file included from /home/mineq/third_party/boost_1_43_0/boost/proto/core.hpp:13, /home/mineq/third_party/boost_1_43_0/boost/utility/enable_if.hpp:59: instantiated from ‘boost::disable_if<boost::proto::result_of::is_expr<boost::proto::exprns_::expr<boost::proto::tag::terminal, boost::proto::argsns_::term<InputGrammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MockExpressionNode>()>, 0l>, void>, void>’ /home/mineq/third_party/boost_1_43_0/boost/spirit/home/support/meta_compiler.hpp:200: instantiated from ‘boost::spirit::result_of::compile<boost::spirit::qi::domain, InputGrammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MockExpressionNode>(), boost::fusion::unused_type, void>’ /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/parse.hpp:107: instantiated from ‘bool boost::spirit::qi::phrase_parse(Iterator&, Iterator, const Expr&, const Skipper&, boost::spirit::qi::skip_flag::enum_type, Attr&) [with Iterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Expr = InputGrammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MockExpressionNode>(), Skipper = MockExpressionNode, Attr = const boost::proto::exprns_::expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, 0l>]’ /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/parse.hpp:125: instantiated from ‘bool boost::spirit::qi::phrase_parse(Iterator&, Iterator, const Expr&, const Skipper&, Attr&) [with Iterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Expr = InputGrammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MockExpressionNode>(), Skipper = MockExpressionNode, Attr = const boost::spirit::ascii::space_type]’ tests_main.cpp:206: instantiated from here /home/mineq/third_party/boost_1_43_0/boost/proto/detail/expr0.hpp:64: error: field ‘boost::proto::exprns_::expr<boost::proto::tag::terminal, boost::proto::argsns_::term<InputGrammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MockExpressionNode>()>, 0l>::child0’ invalidly declared function type from /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/auto.hpp:16, from /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi.hpp:15, from /home/mineq/third_party/boost_1_43_0/boost/spirit/include/qi.hpp:16, from ../InputParser/InputGrammar.h:12, from tests_main.cpp:14: /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/parse.hpp: In function ‘bool boost::spirit::qi::phrase_parse(Iterator&, Iterator, const Expr&, const Skipper&, boost::spirit::qi::skip_flag::enum_type, Attr&) [with Iterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Expr = InputGrammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MockExpressionNode>(), Skipper = MockExpressionNode, Attr = const boost::proto::exprns_::expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, 0l>]’: In file included from /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/detail/parse_auto.hpp:14, /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/parse.hpp:125: instantiated from ‘bool boost::spirit::qi::phrase_parse(Iterator&, Iterator, const Expr&, const Skipper&, Attr&) [with Iterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Expr = InputGrammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MockExpressionNode>(), Skipper = MockExpressionNode, Attr = const boost::spirit::ascii::space_type]’ tests_main.cpp:206: instantiated from here /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/parse.hpp:107: error: request for member ‘parse’ in ‘boost::spirit::compile [with Domain = boost::spirit::qi::domain, Expr = InputGrammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MockExpressionNode>()](((InputGrammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MockExpressionNode> (&)())((InputGrammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MockExpressionNode> (*)())expr)))’, which is of non-class type ‘InputGrammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MockExpressionNode>()’ from /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/auto.hpp:15, from /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi.hpp:15, from /home/mineq/third_party/boost_1_43_0/boost/spirit/include/qi.hpp:16, from ../InputParser/InputGrammar.h:12, from tests_main.cpp:14: /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/skip_over.hpp: In function ‘void boost::spirit::qi::skip_over(Iterator&, const Iterator&, const T&) [with Iterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, T = boost::spirit::qi::phrase_parse(Iterator&, Iterator, const Expr&, const Skipper&, boost::spirit::qi::skip_flag::enum_type, Attr&) [with Iterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Expr = InputGrammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MockExpressionNode>(), Skipper = MockExpressionNode, Attr = const boost::proto::exprns_::expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, 0l>]::skipper_type]’: In file included from /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/auto/auto.hpp:19, /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/parse.hpp:112: instantiated from ‘bool boost::spirit::qi::phrase_parse(Iterator&, Iterator, const Expr&, const Skipper&, boost::spirit::qi::skip_flag::enum_type, Attr&) [with Iterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Expr = InputGrammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MockExpressionNode>(), Skipper = MockExpressionNode, Attr = const boost::proto::exprns_::expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, 0l>]’ /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/parse.hpp:125: instantiated from ‘bool boost::spirit::qi::phrase_parse(Iterator&, Iterator, const Expr&, const Skipper&, Attr&) [with Iterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Expr = InputGrammar<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MockExpressionNode>(), Skipper = MockExpressionNode, Attr = const boost::spirit::ascii::space_type]’ tests_main.cpp:206: instantiated from here /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/skip_over.hpp:27: error: ‘const struct MockExpressionNode’ has no member named ‘parse’ make[2]: *** [build/linux_amd64_devel/GNU-Linux-x86/tests_main.o] Error 1 make[2]: se sale del directorio `/home/mineq/NetBeansProjects/InputParserTests' make[1]: *** [.build-conf] Error 2 make[1]: se sale del directorio `/home/mineq/NetBeansProjects/InputParserTests' make: *** [.build-impl] Error 2 BUILD FAILED (exit value 2, total time: 1m 48s)

    Read the article

  • build error with boost spirit grammar (boost 1.43 and g++ 4.4.1) part II

    - by lurscher
    I'm having issues getting a small spirit/qi grammar to compile. i am using boost 1.43 and g++ 4.4.1. the input grammar header: inputGrammar.h #include <boost/config/warning_disable.hpp> #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/phoenix_core.hpp> #include <boost/spirit/include/phoenix_operator.hpp> #include <boost/spirit/include/phoenix_fusion.hpp> #include <boost/spirit/include/phoenix_stl.hpp> #include <boost/fusion/include/adapt_struct.hpp> #include <boost/variant/recursive_variant.hpp> #include <boost/foreach.hpp> #include <iostream> #include <fstream> #include <string> #include <vector> namespace sp = boost::spirit; namespace qi = boost::spirit::qi; using namespace boost::spirit::ascii; //using namespace boost::spirit::arg_names; namespace fusion = boost::fusion; namespace phoenix = boost::phoenix; using phoenix::at_c; using phoenix::push_back; template< typename Iterator , typename ExpressionAST > struct InputGrammar : qi::grammar<Iterator, ExpressionAST(), space_type> { InputGrammar() : InputGrammar::base_type( block ) { tag = sp::lexeme[+(alpha) [sp::_val += sp::_1]];//[+(char_ - '<') [_val += _1]]; block = sp::lit("block") [ at_c<0>(sp::_val) = sp::_1] >> "(" >> *instruction[ push_back( at_c<1>(sp::_val) , sp::_1 ) ] >> ")"; command = tag [ at_c<0>(sp::_val) = sp::_1] >> "(" >> *instruction [ push_back( at_c<1>(sp::_val) , sp::_1 )] >> ")"; instruction = ( command | tag ) [sp::_val = sp::_1]; } qi::rule< Iterator , std::string() , space_type > tag; qi::rule< Iterator , ExpressionAST() , space_type > block; qi::rule< Iterator , ExpressionAST() , space_type > function_def; qi::rule< Iterator , ExpressionAST() , space_type > command; qi::rule< Iterator , ExpressionAST() , space_type > instruction; }; the test build program: #include <iostream> #include <string> #include <vector> using namespace std; //my grammar #include <InputGrammar.h> struct MockExpressionNode { std::string name; std::vector< MockExpressionNode > operands; typedef std::vector< MockExpressionNode >::iterator iterator; typedef std::vector< MockExpressionNode >::const_iterator const_iterator; iterator begin() { return operands.begin(); } const_iterator begin() const { return operands.begin(); } iterator end() { return operands.end(); } const_iterator end() const { return operands.end(); } bool is_leaf() const { return ( operands.begin() == operands.end() ); } }; BOOST_FUSION_ADAPT_STRUCT( MockExpressionNode, (std::string, name) (std::vector<MockExpressionNode>, operands) ) int const tabsize = 4; void tab(int indent) { for (int i = 0; i < indent; ++i) std::cout << ' '; } template< typename ExpressionNode > struct ExpressionNodePrinter { ExpressionNodePrinter(int indent = 0) : indent(indent) { } void operator()(ExpressionNode const& node) const { cout << " tag: " << node.name << endl; for (int i=0 ; i < node.operands.size() ; i++ ) { tab( indent ); cout << " arg "<<i<<": "; ExpressionNodePrinter(indent + 2)( node.operands[i]); cout << endl; } } int indent; }; int test() { MockExpressionNode root; InputGrammar< string::const_iterator , MockExpressionNode > g; std::string litA = "litA"; std::string litB = "litB"; std::string litC = "litC"; std::string litD = "litD"; std::string litE = "litE"; std::string litF = "litF"; std::string source = litA+"( "+litB+" ,"+litC+" , "+ litD+" ( "+litE+", "+litF+" ) "+ " )"; string::const_iterator iter = source.begin(); string::const_iterator end = source.end(); bool r = qi::phrase_parse( iter , end , g , space , root ); ExpressionNodePrinter< MockExpressionNode > np; np( root ); }; int main() { test(); } finally, the build error is the following: (the full error trace is 20 times bigger than the allowed size for a stackoverflow question, so i posted the full version of it at http://codepad.org/Q74IVCUc) /usr/bin/make -f nbproject/Makefile-linux_amd64_devel.mk SUBPROJECTS= .build-conf make[1]: se ingresa al directorio `/home/mineq/NetBeansProjects/InputParserTests' /usr/bin/make -f nbproject/Makefile-linux_amd64_devel.mk dist/linux_amd64_devel/GNU-Linux-x86/vpuinputparsertests make[2]: se ingresa al directorio `/home/mineq/NetBeansProjects/InputParserTests' mkdir -p build/linux_amd64_devel/GNU-Linux-x86 rm -f build/linux_amd64_devel/GNU-Linux-x86/tests_main.o.d g++ `llvm-config --cxxflags` `pkg-config --cflags unittest-cpp` `pkg-config --cflags boost-1.43` `pkg-config --cflags boost-coroutines` -c -g -I../InputParser -MMD -MP -MF build/linux_amd64_devel/GNU-Linux-x86/tests_main.o.d -o build/linux_amd64_devel/GNU-Linux-x86/tests_main.o tests_main.cpp from /home/mineq/third_party/boost_1_43_0/boost/spirit/include/phoenix_operator.hpp:11, from ../InputParser/InputGrammar.h:14, from tests_main.cpp:14: /home/mineq/third_party/boost_1_43_0/boost/spirit/home/phoenix/operator/self.hpp: In instantiation of ‘const int boost::phoenix::result_of_assign<MockExpressionNode&, boost::variant<MockExpressionNode, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_>&>::size’: In file included from /home/mineq/third_party/boost_1_43_0/boost/spirit/home/phoenix/operator.hpp:16, /home/mineq/third_party/boost_1_43_0/boost/spirit/home/phoenix/operator/self.hpp:27: instantiated from ‘const int boost::phoenix::result_of_assign<MockExpressionNode&, boost::variant<MockExpressionNode, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_>&>::index’ /home/mineq/third_party/boost_1_43_0/boost/spirit/home/phoenix/operator/self.hpp:27: instantiated from ‘boost::phoenix::result_of_assign<MockExpressionNode&, boost::variant<MockExpressionNode, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_>&>’ /home/mineq/third_party/boost_1_43_0/boost/mpl/eval_if.hpp:38: instantiated from ‘boost::mpl::eval_if<boost::mpl::or_<boost::phoenix::is_actor<MockExpressionNode&>, boost::phoenix::is_actor<boost::variant<MockExpressionNode, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_>&>, mpl_::bool_<false>, mpl_::bool_<false>, mpl_::bool_<false> >, boost::phoenix::re_curry<boost::phoenix::assign_eval, MockExpressionNode&, boost::variant<MockExpressionNode, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_>&, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_>, boost::phoenix::result_of_assign<MockExpressionNode&, boost::variant<MockExpressionNode, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_>&> >’ /home/mineq/third_party/boost_1_43_0/boost/spirit/home/phoenix/operator/self.hpp:69: instantiated from ‘boost::phoenix::assign_eval::result<boost::phoenix::basic_environment<boost::fusion::vector1<boost::variant<MockExpressionNode, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_>&>, boost::spirit::context<boost::fusion::cons<MockExpressionNode&, boost::fusion::nil>, boost::fusion::vector0<void> >, bool, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_>, boost::spirit::attribute<0>, boost::spirit::argument<0> >’ /home/mineq/third_party/boost_1_43_0/boost/spirit/home/phoenix/core/detail/composite_eval.hpp:89: instantiated from ‘boost::phoenix::detail::composite_eval<2>::result<boost::phoenix::composite<boost::phoenix::assign_eval, boost::fusion::vector<boost::spirit::attribute<0>, boost::spirit::argument<0>, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_> >, boost::phoenix::basic_environment<boost::fusion::vector1<boost::variant<MockExpressionNode, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_>&>, boost::spirit::context<boost::fusion::cons<MockExpressionNode&, boost::fusion::nil>, boost::fusion::vector0<void> >, bool, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_> >’ /home/mineq/third_party/boost_1_43_0/boost/spirit/home/phoenix/core/composite.hpp:61: instantiated from ‘boost::phoenix::composite<boost::phoenix::assign_eval, boost::fusion::vector<boost::spirit::attribute<0>, boost::spirit::argument<0>, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_> >::result<boost::phoenix::basic_environment<boost::fusion::vector1<boost::variant<MockExpressionNode, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_>&>, boost::spirit::context<boost::fusion::cons<MockExpressionNode&, boost::fusion::nil>, boost::fusion::vector0<void> >, bool, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_> >’ /home/mineq/third_party/boost_1_43_0/boost/spirit/home/phoenix/core/actor.hpp:56: instantiated from ‘boost::phoenix::eval_result<boost::phoenix::composite<boost::phoenix::assign_eval, boost::fusion::vector<boost::spirit::attribute<0>, boost::spirit::argument<0>, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_> >, boost::phoenix::basic_environment<boost::fusion::vector1<boost::variant<MockExpressionNode, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_>&>, boost::spirit::context<boost::fusion::cons<MockExpressionNode&, boost::fusion::nil>, boost::fusion::vector0<void> >, bool, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_> >’ /home/mineq/third_party/boost_1_43_0/boost/spirit/home/phoenix/core/actor.hpp:65: instantiated from ‘boost::phoenix::actor<boost::phoenix::composite<boost::phoenix::assign_eval, boost::fusion::vector<boost::spirit::attribute<0>, boost::spirit::argument<0>, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_> > >::result<boost::phoenix::actor<boost::phoenix::composite<boost::phoenix::assign_eval, boost::fusion::vector<boost::spirit::attribute<0>, boost::spirit::argument<0>, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_> > >(boost::fusion::vector1<boost::variant<MockExpressionNode, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_>&>&, boost::spirit::context<boost::fusion::cons<MockExpressionNode&, boost::fusion::nil>, boost::fusion::vector0<void> >&, bool&)>’ /home/mineq/third_party/boost_1_43_0/boost/spirit/home/support/action_dispatch.hpp:44: instantiated from ‘bool boost::spirit::traits::action_dispatch<Component>::operator()(const boost::phoenix::actor<Eval>&, Attribute&, Context&) [with Eval = boost::phoenix::composite<boost::phoenix::assign_eval, boost::fusion::vector<boost::spirit::attribute<0>, boost::spirit::argument<0>, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_> >, Attribute = boost::variant<MockExpressionNode, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_>, Context = boost::spirit::context<boost::fusion::cons<MockExpressionNode&, boost::fusion::nil>, boost::fusion::vector0<void> >, Component = boost::spirit::qi::alternative<boost::fusion::cons<boost::spirit::qi::reference<const boost::spirit::qi::rule<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MockExpressionNode(), boost::proto::exprns_::expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, 0l>, boost::fusion::unused_type, boost::fusion::unused_type> >, boost::fusion::cons<boost::spirit::qi::reference<const boost::spirit::qi::rule<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::string(), boost::proto::exprns_::expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, 0l>, boost::fusion::unused_type, boost::fusion::unused_type> >, boost::fusion::nil> > >]’ /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/action/action.hpp:62: instantiated from ‘bool boost::spirit::qi::action<Subject, Action>::parse(Iterator&, const Iterator&, Context&, const Skipper&, Attribute&) const [with Iterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Context = boost::spirit::context<boost::fusion::cons<MockExpressionNode&, boost::fusion::nil>, boost::fusion::vector0<void> >, Skipper = boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, Attribute = const boost::fusion::unused_type, Subject = boost::spirit::qi::alternative<boost::fusion::cons<boost::spirit::qi::reference<const boost::spirit::qi::rule<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MockExpressionNode(), boost::proto::exprns_::expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, 0l>, boost::fusion::unused_type, boost::fusion::unused_type> >, boost::fusion::cons<boost::spirit::qi::reference<const boost::spirit::qi::rule<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::string(), boost::proto::exprns_::expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, 0l>, boost::fusion::unused_type, boost::fusion::unused_type> >, boost::fusion::nil> > >, Action = boost::phoenix::actor<boost::phoenix::composite<boost::phoenix::assign_eval, boost::fusion::vector<boost::spirit::attribute<0>, boost::spirit::argument<0>, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_> > >]’ /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/nonterminal/detail/parser_binder.hpp:33: instantiated from ‘bool boost::spirit::qi::detail::parser_binder<Parser, Auto>::call(Iterator&, const Iterator&, Context&, const Skipper&, mpl_::true_) const [with Iterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Skipper = boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, Context = boost::spirit::context<boost::fusion::cons<MockExpressionNode&, boost::fusion::nil>, boost::fusion::vector0<void> >, Parser = boost::spirit::qi::action<boost::spirit::qi::alternative<boost::fusion::cons<boost::spirit::qi::reference<const boost::spirit::qi::rule<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MockExpressionNode(), boost::proto::exprns_::expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, 0l>, boost::fusion::unused_type, boost::fusion::unused_type> >, boost::fusion::cons<boost::spirit::qi::reference<const boost::spirit::qi::rule<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::string(), boost::proto::exprns_::expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, 0l>, boost::fusion::unused_type, boost::fusion::unused_type> >, boost::fusion::nil> > >, boost::phoenix::actor<boost::phoenix::composite<boost::phoenix::assign_eval, boost::fusion::vector<boost::spirit::attribute<0>, boost::spirit::argument<0>, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_> > > >, Auto = mpl_::bool_<false>]’ /home/mineq/third_party/boost_1_43_0/boost/spirit/home/qi/nonterminal/detail/parser_binder.hpp:53: instantiated from ‘bool boost::spirit::qi::detail::parser_binder<Parser, Auto>::operator()(Iterator&, const Iterator&, Context&, const Skipper&) const [with Iterator = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Skipper = boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, Context = boost::spirit::context<boost::fusion::cons<MockExpressionNode&, boost::fusion::nil>, boost::fusion::vector0<void> >, Parser = boost::spirit::qi::action<boost::spirit::qi::alternative<boost::fusion::cons<boost::spirit::qi::reference<const boost::spirit::qi::rule<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, MockExpressionNode(), boost::proto::exprns_::expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, 0l>, boost::fusion::unused_type, boost::fusion::unused_type> >, boost::fusion::cons<boost::spirit::qi::reference<const boost::spirit::qi::rule<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::string(), boost::proto::exprns_::expr<boost::proto::tag::terminal, boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >, 0l>, boost::fusion::unused_type, boost::fusion::unused_type> >, boost::fusion::nil> > >, ... ... more errors but i had to truncate to fit the 30k limit make[2]: *** [build/linux_amd64_devel/GNU-Linux-x86/tests_main.o] Error 1 make[2]: se sale del directorio `/home/mineq/NetBeansProjects/InputParserTests' make[1]: *** [.build-conf] Error 2 make[1]: se sale del directorio `/home/mineq/NetBeansProjects/InputParserTests' make: *** [.build-impl] Error 2 BUILD FAILED (exit value 2, total time: 2m 13s)

    Read the article

  • Linking errors when building against Boost Unit Test Framework

    - by Rafid
    I am trying to use Boost Unit Test Framework by building a stand alone library as detailed here: http://www.boost.org/doc/libs/1_35_0/libs/test/doc/components/utf/compilation.html So I created a VC library project containing the mentioned files and build it and it was successful. Then I created a test project and referenced the library project I just created, but when I tried to build it, I got the following linking errors: 1>Type.obj : error LNK2019: unresolved external symbol "bool __cdecl boost::test_tools::tt_detail::check_impl(class boost::test_tools::predicate_result const &,class boost::unit_test::lazy_ostream const &,class boost::unit_test::basic_cstring<char const >,unsigned __int64,enum boost::test_tools::tt_detail::tool_level,enum boost::test_tools::tt_detail::check_type,unsigned __int64,...)" (?check_impl@tt_detail@test_tools@boost@@YA_NAEBVpredicate_result@23@AEBVlazy_ostream@unit_test@3@V?$basic_cstring@$$CBD@63@_KW4tool_level@123@W4check_type@123@3ZZ) referenced in function "public: void __cdecl test1::test_method(void)" (?test_method@test1@@QEAAXXZ) 1>BoostUnitTestFramework.lib(framework.obj) : error LNK2019: unresolved external symbol "void __cdecl boost::debug::break_memory_alloc(long)" (?break_memory_alloc@debug@boost@@YAXJ@Z) referenced in function "void __cdecl boost::unit_test::framework::init(class boost::unit_test::test_suite * (__cdecl*)(int,char * * const),int,char * * const)" (?init@framework@unit_test@boost@@YAXP6APEAVtest_suite@23@HQEAPEAD@ZH0@Z) 1>BoostUnitTestFramework.lib(framework.obj) : error LNK2019: unresolved external symbol "void __cdecl boost::debug::detect_memory_leaks(bool)" (?detect_memory_leaks@debug@boost@@YAX_N@Z) referenced in function "void __cdecl boost::unit_test::framework::init(class boost::unit_test::test_suite * (__cdecl*)(int,char * * const),int,char * * const)" (?init@framework@unit_test@boost@@YAXP6APEAVtest_suite@23@HQEAPEAD@ZH0@Z) 1>BoostUnitTestFramework.lib(execution_monitor.obj) : error LNK2019: unresolved external symbol "bool __cdecl boost::debug::attach_debugger(bool)" (?attach_debugger@debug@boost@@YA_N_N@Z) referenced in function "public: int __cdecl boost::detail::system_signal_exception::operator()(unsigned int,struct _EXCEPTION_POINTERS *)" (??Rsystem_signal_exception@detail@boost@@QEAAHIPEAU_EXCEPTION_POINTERS@@@Z) 1>BoostUnitTestFramework.lib(execution_monitor.obj) : error LNK2019: unresolved external symbol "bool __cdecl boost::debug::under_debugger(void)" (?under_debugger@debug@boost@@YA_NXZ) referenced in function "public: int __cdecl boost::execution_monitor::execute(class boost::unit_test::callback0<int> const &)" (?execute@execution_monitor@boost@@QEAAHAEBV?$callback0@H@unit_test@2@@Z) 1>BoostUnitTestFramework.lib(unit_test_main.obj) : error LNK2019: unresolved external symbol "class boost::unit_test::test_suite * __cdecl init_unit_test_suite(int,char * * const)" (?init_unit_test_suite@@YAPEAVtest_suite@unit_test@boost@@HQEAPEAD@Z) referenced in function main 1>C:\Users\Rafid\Workspace\MyPhysics\Builds\VC10\Tests\Debug\Tests.exe : fatal error LNK1120: 6 unresolved externals They seem to be mainly caused by Boost debug library, but I can't see a reason why I should get linking errors putting in mind that Boost debug library only need to be included as header files, rather than linking against as a library! Any ideas?!

    Read the article

  • boost::function & boost::lambda again

    - by John Dibling
    Follow-up to post: http://stackoverflow.com/questions/2978096/using-width-precision-specifiers-with-boostformat I'm trying to use boost::function to create a function that uses lambdas to format a string with boost::format. Ultimately what I'm trying to achieve is using width & precision specifiers for strings with format. boost::format does not support the use of the * width & precision specifiers, as indicated in the docs: Width or precision set to asterisk (*) are used by printf to read this field from an argument. e.g. printf("%1$d:%2$.*3$d:%4$.*3$d\n", hour, min, precision, sec); This class does not support this mechanism for now. so such precision or width fields are quietly ignored by the parsing. so I'm trying to find other ways to accomplish the same goal. Here is what I have so far, which isn't working: #include <string> #include <boost\function.hpp> #include <boost\lambda\lambda.hpp> #include <iostream> #include <boost\format.hpp> #include <iomanip> #include <boost\bind.hpp> int main() { using namespace boost::lambda; using namespace std; boost::function<std::string(int, std::string)> f = (boost::format("%s") % boost::io::group(setw(_1*2), setprecision(_2*2), _3)).str(); std::string s = (boost::format("%s") % f(15, "Hello")).str(); return 0; } This generates many compiler errors: 1>------ Build started: Project: hacks, Configuration: Debug x64 ------ 1>Compiling... 1>main.cpp 1>.\main.cpp(15) : error C2872: '_1' : ambiguous symbol 1> could be 'D:\Program Files (x86)\boost\boost_1_42\boost/lambda/core.hpp(69) : boost::lambda::placeholder1_type &boost::lambda::`anonymous-namespace'::_1' 1> or 'D:\Program Files (x86)\boost\boost_1_42\boost/bind/placeholders.hpp(43) : boost::arg<I> `anonymous-namespace'::_1' 1> with 1> [ 1> I=1 1> ] 1>.\main.cpp(15) : error C2664: 'std::setw' : cannot convert parameter 1 from 'boost::lambda::placeholder1_type' to 'std::streamsize' 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 1>.\main.cpp(15) : error C2872: '_2' : ambiguous symbol 1> could be 'D:\Program Files (x86)\boost\boost_1_42\boost/lambda/core.hpp(70) : boost::lambda::placeholder2_type &boost::lambda::`anonymous-namespace'::_2' 1> or 'D:\Program Files (x86)\boost\boost_1_42\boost/bind/placeholders.hpp(44) : boost::arg<I> `anonymous-namespace'::_2' 1> with 1> [ 1> I=2 1> ] 1>.\main.cpp(15) : error C2664: 'std::setprecision' : cannot convert parameter 1 from 'boost::lambda::placeholder2_type' to 'std::streamsize' 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 1>.\main.cpp(15) : error C2872: '_3' : ambiguous symbol 1> could be 'D:\Program Files (x86)\boost\boost_1_42\boost/lambda/core.hpp(71) : boost::lambda::placeholder3_type &boost::lambda::`anonymous-namespace'::_3' 1> or 'D:\Program Files (x86)\boost\boost_1_42\boost/bind/placeholders.hpp(45) : boost::arg<I> `anonymous-namespace'::_3' 1> with 1> [ 1> I=3 1> ] 1>.\main.cpp(15) : error C2660: 'boost::io::group' : function does not take 3 arguments 1>.\main.cpp(15) : error C2228: left of '.str' must have class/struct/union 1>Build log was saved at "file://c:\Users\john\Documents\Visual Studio 2005\Projects\hacks\x64\Debug\BuildLog.htm" 1>hacks - 7 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== My fundamental understanding of boost's lambdas and functions is probably lacking. How can I get this to work?

    Read the article

  • Using a boost::fusion::map in boost::spirit::karma

    - by user1097105
    I am using boost spirit to parse some text files into a data structure and now I am beginning to generate text from this data structure (using spirit karma). One attempt at a data structure is a boost::fusion::map (as suggested in an answer to this question). But although I can use boost::spirit::qi::parse() and get data in it easily, when I tried to generate text from it using karma, I failed. Below is my attempt (look especially at the "map_data" type). After some reading and playing around with other fusion types, I found boost::fusion::vector and BOOST_FUSION_DEFINE_ASSOC_STRUCT. I succeeded to generate output with both of them, but they don't seem ideal: in vector you cannot access a member using a name (it is like a tuple) -- and in the other solution, I don't think I need both ways (member name and key type) to access the members. #include <iostream> #include <string> #include <boost/spirit/include/karma.hpp> #include <boost/fusion/include/map.hpp> #include <boost/fusion/include/make_map.hpp> #include <boost/fusion/include/vector.hpp> #include <boost/fusion/include/as_vector.hpp> #include <boost/fusion/include/transform.hpp> struct sb_key; struct id_key; using boost::fusion::pair; typedef boost::fusion::map < pair<sb_key, int> , pair<id_key, unsigned long> > map_data; typedef boost::fusion::vector < int, unsigned long > vector_data; #include <boost/fusion/include/define_assoc_struct.hpp> BOOST_FUSION_DEFINE_ASSOC_STRUCT( (), assocstruct_data, (int, a, sb_key) (unsigned long, b, id_key)) namespace karma = boost::spirit::karma; template <typename X> std::string to_string ( const X& data ) { std::string generated; std::back_insert_iterator<std::string> sink(generated); karma::generate_delimited ( sink, karma::int_ << karma::ulong_, karma::space, data ); return generated; } int main() { map_data d1(boost::fusion::make_map<sb_key, id_key>(234, 35314988526ul)); vector_data d2(boost::fusion::make_vector(234, 35314988526ul)); assocstruct_data d3(234,35314988526ul); std::cout << "map_data as_vector: " << boost::fusion::as_vector(d1) << std::endl; //std::cout << "map_data to_string: " << to_string(d1) << std::endl; //*FAIL No 1* std::cout << "at_key (sb_key): " << boost::fusion::at_key<sb_key>(d1) << boost::fusion::at_c<0>(d1) << std::endl << std::endl; std::cout << "vector_data: " << d2 << std::endl; std::cout << "vector_data to_string: " << to_string(d2) << std::endl << std::endl; std::cout << "assoc_struct as_vector: " << boost::fusion::as_vector(d3) << std::endl; std::cout << "assoc_struct to_string: " << to_string(d3) << std::endl; std::cout << "at_key (sb_key): " << boost::fusion::at_key<sb_key>(d3) << d3.a << boost::fusion::at_c<0>(d3) << std::endl; return 0; } Including the commented line gives lots of pages of compilation errors, among which notably something like: no known conversion for argument 1 from ‘boost::fusion::pair’ to ‘double’ no known conversion for argument 1 from ‘boost::fusion::pair’ to ‘float’ Might it be that to_string needs the values of the map_data, and not the pairs? Though I am not good with templates, I tried to get a vector from a map using transform in the following way template <typename P> struct take_second { typename P::second_type operator() (P p) { return p.second; } }; // ... inside main() pair <char, int> ff(32); std::cout << "take_second (expect 32): " << take_second<pair<char,int>>()(ff) << std::endl; std::cout << "transform map_data and to_string: " << to_string(boost::fusion::transform(d1, take_second<>())); //*FAIL No 2* But I don't know what types am I supposed to give when instantiating take_second and anyway I think there must be an easier way to get (iterate over) the values of a map (is there?) If you answer this question, please also give your opinion on whether using an ASSOC_STRUCT or a map is better.

    Read the article

  • C: Random Number Generation - What (If Anything) Is Wrong With This

    - by raoulcousins
    For a simple simulation in C, I need to generate exponential random variables. I remember reading somewhere (but I can't find it now, and I don't remember why) that using the rand() function to generate random integers in a fixed range would generate non-uniformly distributed integers. Because of this, I'm wondering if this code might have a similar problem: //generate u ~ U[0,1] u = ( (double)rand() / ((double)(RAND_MAX)); //inverse of exponential CDF to get exponential random variable expon = -log(1-u) * mean; Thank you!

    Read the article

  • boost fusion: strange problem depending on number of elements on a vector

    - by ChAoS
    I am trying to use Boost::Fusion (Boost v1.42.0) in a personal project. I get an interesting error with this code: #include "boost/fusion/include/sequence.hpp" #include "boost/fusion/include/make_vector.hpp" #include "boost/fusion/include/insert.hpp" #include "boost/fusion/include/invoke_procedure.hpp" #include "boost/fusion/include/make_vector.hpp" #include <iostream> class Class1 { public: typedef boost::fusion::vector<int,float,float,char,int,int> SequenceType; SequenceType s; Class1(SequenceType v):s(v){} }; class Class2 { public: Class2(){} void met(int a,float b ,float c ,char d ,int e,int f) { std::cout << a << " " << b << " " << c << " " << d << " " << e << std::endl; } }; int main(int argn, char**) { Class2 p; Class1 t(boost::fusion::make_vector(9,7.66f,8.99f,'s',7,6)); boost::fusion::begin(t.s); //OK boost::fusion::insert(t.s, boost::fusion::begin(t.s), &p); //OK boost::fusion::invoke_procedure(&Class2::met,boost::fusion::insert(t.s, boost::fusion::begin(t.s), &p)); //FAILS } It fails to compile (gcc 4.4.1): In file included from /home/thechaos/Escriptori/of_preRelease_v0061_linux_FAT/addons/ofxTableGestures/ext/boost/fusion/include/invoke_procedur e.hpp:10, from problema concepte.cpp:11: /home/thechaos/Escriptori/of_preRelease_v0061_linux_FAT/addons/ofxTableGestures/ext/boost/fusion/functional/invocation/invoke_procedure.hpp: I n function ‘void boost::fusion::invoke_procedure(Function, const Sequence&) [with Function = void (Class2::*)(int, float, float, char, int, in t), Sequence = boost::fusion::joint_view<boost::fusion::joint_view<boost::fusion::iterator_range<boost::fusion::vector_iterator<const boost::f usion::vector<int, float, float, char, int, int, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_>, 0>, boost::fusion::vector_iterator<boost::fusion::vector<int, float, float, char, int, int, boost::fusion::void_, boost::fusion::void_, boost::fus ion::void_, boost::fusion::void_>, 0> >, const boost::fusion::single_view<Class2*> >, boost::fusion::iterator_range<boost::fusion::vector_iter ator<boost::fusion::vector<int, float, float, char, int, int, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion: :void_>, 0>, boost::fusion::vector_iterator<const boost::fusion::vector<int, float, float, char, int, int, boost::fusion::void_, boost::fusion ::void_, boost::fusion::void_, boost::fusion::void_>, 6> > >]’: problema concepte.cpp:39: instantiated from here /home/thechaos/Escriptori/of_preRelease_v0061_linux_FAT/addons/ofxTableGestures/ext/boost/fusion/functional/invocation/invoke_procedure.hpp:88 : error: incomplete type ‘boost::fusion::detail::invoke_procedure_impl<void (Class2::*)(int, float, float, char, int, int), const boost::fusio n::joint_view<boost::fusion::joint_view<boost::fusion::iterator_range<boost::fusion::vector_iterator<const boost::fusion::vector<int, float, f loat, char, int, int, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_>, 0>, boost::fusion::vector_itera tor<boost::fusion::vector<int, float, float, char, int, int, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion:: void_>, 0> >, const boost::fusion::single_view<Class2*> >, boost::fusion::iterator_range<boost::fusion::vector_iterator<boost::fusion::vector< int, float, float, char, int, int, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_, boost::fusion::void_>, 0>, boost::fusion: :vector_iterator<const boost::fusion::vector<int, float, float, char, int, int, boost::fusion::void_, boost::fusion::void_, boost::fusion::voi d_, boost::fusion::void_>, 6> > >, 7, true, false>’ used in nested name specifier However, if I change the number of arguments in the vectors and the method from 6 to 5 from int,float,float,char,int,int to int,float,float,char,int,I can compile it without problems. I suspected about the maximum number of arguments being a limitation, but I tried to change it through defining FUSION_MAX_VECTOR_SIZE without success. I am unable to see what am I doing wrong. Can you reproduce this? Can it be a boost bug (i doubt it but is not impossible)?

    Read the article

  • Boost tuple + transform

    - by JH
    Is it possible to do the following. Say my boost tuple has <String, int> I would like to use std::transform + mem_fun to insert only the String element in a corresponding vector. Is it possible or are we required to use a loop and push_back(get<0) Ie the following doesn't like to compile... (unknown types...) result.resize(storage.size()) std::transform(storage.begin(), storage.end(), result.begin(), std::mem_fun(&boost::get<0>)); Here is an example (trying one of the comments): #include <boost/tuple/tuple.hpp> #include <vector> #include <string> #include <algorithm> int main(int argc, char**argv) { std::vector< boost::tuple<std::string, int> > storage; std::vector< std::string> result; result.resize(storage.size()); std::transform(storage.begin(), storage.end(), result.begin(), &boost::get<0, boost::tuple<std::string, int> >); return 0; } Output: g++ test.cpp /usr/include/boost/tuple/detail/tuple_basic.hpp: In instantiation of `boost::tuples::cons<boost::tuples::tuple<std::string, int, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>, TT>': /usr/include/boost/tuple/detail/tuple_basic.hpp:151: instantiated from `boost::tuples::element<0, boost::tuples::cons<boost::tuples::tuple<std::string, int, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>, TT> >' test.cpp:14: instantiated from here /usr/include/boost/tuple/detail/tuple_basic.hpp:329: error: `boost::tuples::cons<HT, TT>::tail' has incomplete type /usr/include/boost/tuple/detail/tuple_basic.hpp:329: error: invalid use of template type parameter test.cpp: In function `int main(int, char**)': test.cpp:14: error: no matching function for call to `transform(__gnu_cxx::__normal_iterator<boost::tuples::tuple<std::string, int, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>*, std::vector<boost::tuples::tuple<std::string, int, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>, std::allocator<boost::tuples::tuple<std::string, int, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> > > >, __gnu_cxx::__normal_iterator<boost::tuples::tuple<std::string, int, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>*, std::vector<boost::tuples::tuple<std::string, int, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type>, std::allocator<boost::tuples::tuple<std::string, int, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> > > >, __gnu_cxx::__normal_iterator<std::string*, std::vector<std::string, std::allocator<std::string> > >, <unresolved overloaded function type>)'

    Read the article

  • Random Movement for multiple entities

    - by opiop65
    I have this code for a arraylist of entities. All the entities use the same random and so all of them move in the same direction. How can I change it so it generates a new random number for each entity? public void moveFemale() { for(int i = 0; i < 1000; i++){ random = rand.nextInt(99); } if (random >= 0 && random <= 25) { posX -= enemyWalkSpeed; // right } if (random >= 26 && random <= 50) { posX += enemyWalkSpeed; // left } if (random >= 51 && random <= 75) { posY -= enemyWalkSpeed; // up } if (random >= 76 && random <= 100) { posY += enemyWalkSpeed; // down } } Is this correct? public void moveFemale() { for (Female female: GameFrame.females){ female.lastChangedDirectionTime += elapsedTime; if (female.lastChangedDirectionTime >= CHANGE_DIRECTION_TIME) { female.lastChangedDirectionTime = 0; random = rand.nextInt(100); if (random >= 0 && random <= 25) { posX -= enemyWalkSpeed; // right } if (random >= 26 && random <= 50) { posX += enemyWalkSpeed; // left } if (random >= 51 && random <= 75) { posY -= enemyWalkSpeed; // up } if (random >= 76 && random <= 100) { posY += enemyWalkSpeed; // down } } } }

    Read the article

  • Random Between: using random with the instance_create function in GML

    - by CLockeWork
    Hopefully this should be a simple one; I want to restrict the points that instances enter the screen from so they don't come in at the edges. In Game Maker I'm using the following code instance_create(random(room_width), random(-100) - 50, obj_enemy1); to create the instance off screen (create(x, y, ...)) At the moment I'm just using the room_width to define the max width for the random on x, but ideally I want to find a way of defining a max AND min width for the random. I can't figure out how to restrict the range on the x axis to between say 100 and 350. Any help would be appreciated. Cheers

    Read the article

  • How to use boost::bind with non-copyable params, for example boost::promise ?

    - by zhengxi
    Some C++ objects have no copy constructor, but have move constructor. For example, boost::promise. How can I bind those objects using their move constructors ? #include <boost/thread.hpp> void fullfil_1(boost::promise<int>& prom, int x) { prom.set_value(x); } boost::function<void()> get_functor() { // boost::promise is not copyable, but movable boost::promise<int> pi; // compilation error boost::function<void()> f_set_one = boost::bind(&fullfil_1, pi, 1); // compilation error as well boost::function<void()> f_set_one = boost::bind(&fullfil_1, std::move(pi), 1); // PS. I know, it is possible to bind a pointer to the object instead of // the object itself. But it is weird solution, in this case I will have // to take cake about lifetime of the object instead of delegating that to // boost::bind (by moving object into boost::function object) // // weird: pi will be destroyed on leaving the scope boost::function<void()> f_set_one = boost::bind(&fullfil_1, boost::ref(pi), 1); return f_set_one; }

    Read the article

  • How to use Boost 1.41.0 graph layout algorithmes

    - by daniil-k
    Hi I have problem using boost graph layout algorithmes. boost verision 1_41_0 mingw g++ 4.4.0. So there are issues I have encountered Can you suggest me with them? The function fruchterman_reingold_force_directed_layout isn't compiled. The kamada_kawai_spring_layout compiled but program crashed. Boost documentation to layout algorithms is wrong, sample to fruchterman_reingold_force_directed_layout isn't compiled. This is my example. To use function just uncomment one. String 60, 61, 63. #include <boost/config.hpp> #include <boost/graph/adjacency_list.hpp> #include <boost/graph/graph_utility.hpp> #include <boost/graph/simple_point.hpp> #include <boost/property_map/property_map.hpp> #include <boost/graph/circle_layout.hpp> #include <boost/graph/fruchterman_reingold.hpp> #include <boost/graph/kamada_kawai_spring_layout.hpp> #include <iostream> //typedef boost::square_topology<>::point_difference_type Point; typedef boost::square_topology<>::point_type Point; struct VertexProperties { std::size_t index; Point point; }; struct EdgeProperty { EdgeProperty(const std::size_t &w):weight(w) {} double weight; }; typedef boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, VertexProperties, EdgeProperty > Graph; typedef boost::property_map<Graph, std::size_t VertexProperties::*>::type VertexIndexPropertyMap; typedef boost::property_map<Graph, Point VertexProperties::*>::type PositionMap; typedef boost::property_map<Graph, double EdgeProperty::*>::type WeightPropertyMap; typedef boost::graph_traits<Graph>::vertex_descriptor VirtexDescriptor; int main() { Graph graph; VertexIndexPropertyMap vertexIdPropertyMap = boost::get(&VertexProperties::index, graph); for (int i = 0; i < 3; ++i) { VirtexDescriptor vd = boost::add_vertex(graph); vertexIdPropertyMap[vd] = i + 2; } boost::add_edge(boost::vertex(1, graph), boost::vertex(0, graph), EdgeProperty(5), graph); boost::add_edge(boost::vertex(2, graph), boost::vertex(0, graph), EdgeProperty(5), graph); std::cout << "Vertices\n"; boost::print_vertices(graph, vertexIdPropertyMap); std::cout << "Edges\n"; boost::print_edges(graph, vertexIdPropertyMap); PositionMap positionMap = boost::get(&VertexProperties::point, graph); WeightPropertyMap weightPropertyMap = boost::get(&EdgeProperty::weight, graph); boost::circle_graph_layout(graph, positionMap, 100); // boost::fruchterman_reingold_force_directed_layout(graph, positionMap, boost::square_topology<>()); boost::kamada_kawai_spring_layout(graph, positionMap, weightPropertyMap, boost::square_topology<>(), boost::side_length<double>(10), boost::layout_tolerance<>(), 1, vertexIdPropertyMap); std::cout << "Coordinates\n"; boost::graph_traits<Graph>::vertex_iterator i, end; for (boost::tie(i, end) = boost::vertices(graph); i != end; ++i) { std::cout << "ID: (" << vertexIdPropertyMap[*i] << ") x: " << positionMap[*i][0] << " y: " << positionMap[*i][1] << "\n"; } return 0; }

    Read the article

  • Text inside <p> shrinks on mobile devices while div does not [migrated]

    - by guisasso
    I asked this question on stack overflow, but didn't get any answers, so I'm trying here. Does anybody know whats happening here? I tested on opera, dolphin and the factory android browser. (although it seems now to be working on opera) The div doesn't change size, but the text somehow is shrunk to fit on part of a div. Anyway to prevent this? Just to be clear, I'm trying to achieve on the mobile browser the same look as the pc version. As the problem seems to be with the browsers, how can I force the text to take the full width of the div? I tried setting the p tag to 100% with no success. The div has to have that width and be aligned to the left of the page. On a Pc, as it should be: I shrunk the code as much as I could: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-us"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <meta content="" name="keywords" /> <meta content="" name="description" /> <title></title> </head> <body> <div style="width:1000px; margin-left:auto; margin-right:auto;" > <div style="float:left; width:758px; background-color:aqua;"> <p> Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text .<br /> <br /> Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text Random text .<br /> <br /> Random text Random text Random text Random text <a href="http://www.a.com/a.html"> Random text </a> Random text Random text . </p> </div> </div> </body> </html> Thanks.

    Read the article

  • Boost bind with asio::placeholders::error

    - by Leandro
    Why it doesn't work? --- boost_bind.cc --- #include #include #include void func1 (const int& i) { } void func2 (const ::asio::error_code& e) { } int main () { ::boost::function f1 = ::boost::bind (&func1, 1); // it doesn't work! ::boost::function f2 = ::boost::bind (&func2, ::asio::placeholders::error); return 0; } This is the error: while_true@localhost:~ g++ -lpthread boost_bind.cc -o boost_bind In file included from boost_bind.cc:2: /usr/include/boost/bind.hpp: In member function ‘void boost::_bi::list1::operator()(boost::_bi::type, F&, A&, int) [with F = void (*)(const asio::error_code&), A = boost::_bi::list0, A1 = boost::arg (*)()]’: /usr/include/boost/bind/bind_template.hpp:20: instantiated from ‘typename boost::_bi::result_traits::type boost::_bi::bind_t::operator()() [with R = void, F = void (*)(const asio::error_code&), L = boost::_bi::list1 (*)()]’ /usr/include/boost/function/function_template.hpp:152: instantiated from ‘static void boost::detail::function::void_function_obj_invoker0::invoke(boost::detail::function::function_buffer&) [with FunctionObj = boost::_bi::bind_t (*)() , R = void]’ /usr/include/boost/function/function_template.hpp:904: instantiated from ‘void boost::function0::assign_to(Functor) [with Functor = boost::_bi::bind_t (*)() , R = void]’ /usr/include/boost/function/function_template.hpp:720: instantiated from ‘boost::function0::function0(Functor, typename boost::enable_if_c::type) [with Functor = boost::_bi::bind_t (*)() , R = void]’ /usr/include/boost/function/function_template.hpp:1040: instantiated from ‘boost::function::function(Functor, typename boost::enable_if_c::type) [with Functor = boost::_bi::bind_t (*)() , R = void]’ boost_bind.cc:14: instantiated from here /usr/include/boost/bind.hpp:232: error: no match for ‘operator[]’ in ‘a[boost::_bi::storage1 (*)()::a1_ [with int I = 1]]’ while_true@localhost:~

    Read the article

  • How can I use the Boost Graph Library to lay out verticies?

    - by Mike
    I'm trying to lay out vertices using the Boost Graph Library. However, I'm running into some compilation issues which I'm unsure about. Am I using the BGL in an improper manner? My code is: PositionVec position_vec(2); PositionMap position(position_vec.begin(), get(vertex_index, g)); int iterations = 100; double width = 100.0; double height = 100.0; minstd_rand gen; rectangle_topology<> topology(gen, 0, 0, 100, 100); fruchterman_reingold_force_directed_layout(g, position, topology); //Compile fails on this line The diagnostics produced by clang++(I've also tried GCC) are: In file included from test.cpp:2: /Volumes/Data/mike/Downloads/boost_1_43_0/boost/graph/fruchterman_reingold.hpp:95:3: error: no member named 'dimensions' in 'boost::simple_point<double>' BOOST_STATIC_ASSERT (Point::dimensions == 2); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from test.cpp:2: In file included from /Volumes/Data/mike/Downloads/boost_1_43_0/boost/graph/fruchterman_reingold.hpp:13: In file included from /Volumes/Data/mike/Downloads/boost_1_43_0/boost/graph/graph_traits.hpp:15: In file included from /Volumes/Data/mike/Downloads/boost_1_43_0/boost/tuple/tuple.hpp:24: /Volumes/Data/mike/Downloads/boost_1_43_0/boost/static_assert.hpp:118:49: note: instantiated from: sizeof(::boost::STATIC_ASSERTION_FAILURE< BOOST_STATIC_ASSERT_BOOL_CAST( B ) >)>\ ^ In file included from test.cpp:2: /Volumes/Data/mike/Downloads/boost_1_43_0/boost/graph/fruchterman_reingold.hpp:95:3: note: instantiated from: BOOST_STATIC_ASSERT (Point::dimensions == 2); ^ ~~~~~~~ /Volumes/Data/mike/Downloads/boost_1_43_0/boost/graph/fruchterman_reingold.hpp:95:31: note: instantiated from: BOOST_STATIC_ASSERT (Point::dimensions == 2); ~~~~~~~^ /Volumes/Data/mike/Downloads/boost_1_43_0/boost/graph/fruchterman_reingold.hpp:417:19: note: in instantiation of template class 'boost::grid_force_pairs<boost::rectangle_topology<boost::random::linear_congruential<int, 48271, 0, 2147483647, 399268537> >, boost::iterator_property_map<__gnu_cxx::__normal_iterator<boost::simple_point<double> *, std::vector<boost::simple_point<double>, std::allocator<boost::simple_point<double> > > >, boost::vec_adj_list_vertex_id_map<boost::property<boost::vertex_name_t, std::basic_string<char>, boost::no_property>, unsigned long>, boost::simple_point<double>, boost::simple_point<double> &> >' requested here make_grid_force_pairs(topology, position, g)), ^ /Volumes/Data/mike/Downloads/boost_1_43_0/boost/graph/fruchterman_reingold.hpp:431:3: note: in instantiation of function template specialization 'boost::fruchterman_reingold_force_directed_layout<boost::rectangle_topology<boost::random::linear_congruential<int, 48271, 0, 2147483647, 399268537> >, boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS, boost::property<boost::vertex_name_t, std::basic_string<char>, boost::no_property>, boost::no_property, boost::no_property, boost::listS>, boost::iterator_property_map<__gnu_cxx::__normal_iterator<boost::simple_point<double> *, std::vector<boost::simple_point<double>, std::allocator<boost::simple_point<double> > > >, boost::vec_adj_list_vertex_id_map<boost::property<boost::vertex_name_t, std::basic_string<char>, boost::no_property>, unsigned long>, boost::simple_point<double>, boost::simple_point<double> &>, boost::square_distance_attractive_force, boost::attractive_force_t, boost::no_property>' requested here fruchterman_reingold_force_directed_layout ^ test.cpp:48:3: note: in instantiation of function template specialization 'boost::fruchterman_reingold_force_directed_layout<boost::rectangle_topology<boost::random::linear_congruential<int, 48271, 0, 2147483647, 399268537> >, boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS, boost::property<boost::vertex_name_t, std::basic_string<char>, boost::no_property>, boost::no_property, boost::no_property, boost::listS>, boost::iterator_property_map<__gnu_cxx::__normal_iterator<boost::simple_point<double> *, std::vector<boost::simple_point<double>, std::allocator<boost::simple_point<double> > > >, boost::vec_adj_list_vertex_id_map<boost::property<boost::vertex_name_t, std::basic_string<char>, boost::no_property>, unsigned long>, boost::simple_point<double>, boost::simple_point<double> &> >' requested here fruchterman_reingold_force_directed_layout(g, position, topology); ^ 1 error generated.

    Read the article

  • What Causes Boost Asio to Crash Like This?

    - by Scott Lawson
    My program appears to run just fine most of the time, but occasionally I get a segmentation fault. boost version = 1.41.0 running on RHEL 4 compiled with GCC 3.4.6 Backtrace: #0 0x08138546 in boost::asio::detail::posix_fd_set_adapter::is_set (this=0xb74ed020, descriptor=-1) at /home/scottl/boost_1_41_0/boost/asio/detail/posix_fd_set_adapter.hpp:57 __result = -1 'ÿ' #1 0x0813e1b0 in boost::asio::detail::reactor_op_queue::perform_operations_for_descriptors (this=0x97f3b6c, descriptors=@0xb74ed020, result=@0xb74ecec8) at /home/scottl/boost_1_41_0/boost/asio/detail/reactor_op_queue.hpp:204 op_iter = {_M_node = 0xb4169aa0} i = {_M_node = 0x97f3b74} #2 0x081382ca in boost::asio::detail::select_reactor::run (this=0x97f3b08, block=true) at /home/scottl/boost_1_41_0/boost/asio/detail/select_reactor.hpp:388 read_fds = {fd_set_ = {fds_bits = {16, 0 }}, max_descriptor_ = 65} write_fds = {fd_set_ = {fds_bits = {0 }}, max_descriptor_ = -1} retval = 1 lock = { = {}, mutex_ = @0x97f3b1c, locked_ = true} except_fds = {fd_set_ = {fds_bits = {0 }}, max_descriptor_ = -1} max_fd = 65 tv_buf = {tv_sec = 0, tv_usec = 710000} tv = (timeval *) 0xb74ecf88 ec = {m_val = 0, m_cat = 0x81f2c24} sb = { = {}, blocked_ = true, old_mask_ = {__val = {0, 0, 134590223, 3075395548, 3075395548, 3075395464, 134729792, 3075395360, 135890240, 3075395368, 134593920, 3075395544, 135890240, 3075395384, 134599542, 3020998404, 135890240, 3075395400, 134614095, 3075395544, 4, 3075395416, 134548135, 3021172996, 4294967295, 3075395432, 134692921, 3075395504, 0, 3075395448, 134548107, 3021172992}}} #3 0x0812eb45 in boost::asio::detail::task_io_service ::do_one (this=0x97f3a70, lock=@0xb74ed230, this_idle_thread=0xb74ed240, ec=@0xb74ed2c0) at /home/scottl/boost_1_41_0/boost/asio/detail/task_io_service.hpp:260 more_handlers = false c = {lock_ = @0xb74ed230, task_io_service_ = @0x97f3a70} h = (boost::asio::detail::handler_queue::handler *) 0x97f3aa0 polling = false task_has_run = true #4 0x0812765f in boost::asio::detail::task_io_service ::run (this=0x97f3a70, ec=@0xb74ed2c0) at /home/scottl/boost_1_41_0/boost/asio/detail/task_io_service.hpp:103 ctx = { = {}, owner_ = 0x97f3a70, next_ = 0x0} this_idle_thread = {wakeup_event = { = {}, cond_ = {__c_lock = { __status = 0, __spinlock = 22446}, __c_waiting = 0x2bd7, __padding = "\000\000\000\000×+\000\000\000\000\000\000×+\000\000\000\000\000\000\204:\177\t\000\000\000", __align = 0}, signalled_ = true}, next = 0x0} lock = { = {}, mutex_ = @0x97f3a84, locked_ = false} n = 11420 #5 0x08125e99 in boost::asio::io_service::run (this=0x97ebbcc) at /home/scottl/boost_1_41_0/boost/asio/impl/io_service.ipp:58 ec = {m_val = 0, m_cat = 0x81f2c24} s = 8 #6 0x08154424 in boost::_mfi::mf0::operator() (this=0x9800870, p=0x97ebbcc) at /home/scottl/boost_1_41_0/boost/bind/mem_fn_template.hpp:49 No locals. #7 0x08154331 in boost::_bi::list1 ::operator(), boost::_bi::list0 (this=0x9800878, f=@0x9800870, a=@0xb74ed337) at /home/scottl/boost_1_41_0/boost/bind/bind.hpp:236 No locals. #8 0x081541e5 in boost::_bi::bind_t, boost::_bi::list1 ::operator() (this=0x9800870) at /home/scottl/boost_1_41_0/boost/bind/bind_template.hpp:20 a = {} #9 0x08154075 in boost::detail::thread_data, boost::_bi::list1 ::run (this=0x98007a0) at /home/scottl/boost_1_41_0/boost/thread/detail/thread.hpp:56 No locals. #10 0x0816fefd in thread_proxy () at /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/locale_facets.tcc:2443 __ioinit = {static _S_refcount = , static _S_synced_with_stdio = } ---Type to continue, or q to quit--- typeinfo for common::RuntimeException = {} typeinfo name for common::RuntimeException = "N6common16RuntimeExceptionE" #11 0x00af23cc in start_thread () from /lib/tls/libpthread.so.0 No symbol table info available. #12 0x00a5c96e in __init_misc () from /lib/tls/libc.so.6 No symbol table info available.

    Read the article

  • How can I make an even more random number in ActionScript 2.0

    - by Theo
    I write a piece of software that runs inside banner ads which generates millions of session IDs every day. For a long time I've known that the random number generator in Flash is't random enough to generate sufficiently unique IDs, so I've employed a number of tricks to get even more random numbers. However, in ActionScript 2.0 it's not easy, and I'm seeing more and more collisions, so I wonder if there is something I've overlooked. As far as I can tell the problem with Math.random() is that it's seeded by the system time, and when you have sufficient numbers of simultaneous attempts you're bound to see collisions. In ActionScript 3.0 I use the System.totalMemory, but there's no equivalent in ActionScript 2.0. AS3 also has Font.enumerateFonts, and a few other things that are different from system to system. On the server side I also add the IP address to the session ID, but even that isn't enough (for example, many large companies use a single proxy server and that means that thousands of people all have the same IP -- and since they tend to look at the same sites, with the same ads, roughly at the same time, there are many session ID collisions). What I need isn't something perfectly random, just something that is random enough to dilute the randomness I get from Math.random(). Think of it this way: there is a certain chance that two people will generate the same random number sequence using only Math.random(), but the chance of two people generating the same sequence and having, say, the exact same list of fonts is significantly lower. I cannot rely on having sufficient script access to use ExternalInterface to get hold of things like the user agent, or the URL of the page. I don't need suggestions of how to do it in AS3, or any other system, only AS2 -- using only what's available in the standard APIs. The best I've come up with so far is to use the list of microphones (Microphone.names), but I've also tried to make some fingerprinting using some of the properties in System.capabilities, I'm not sure how much randomness I can get out of that though so I'm not using that at the moment. I hope I've overlooked something.

    Read the article

  • make_tuple with boost::python under Visual Studio 9

    - by celil
    Trying to build the following simple example #include <boost/python.hpp> using namespace boost::python; tuple head_and_tail(object sequence) { return make_tuple(sequence[0],sequence[-1]); } available here, I end up with this compilation error under Visual Studio 9 error C2668: 'boost::python::make_tuple' : ambiguous call to overloaded function 1> C:\Program Files\boost_1_42_0\boost/python/detail/make_tuple.hpp(22): could be 'boost::python::tuple boost::python::make_tuple<boost::python::api::object_item,boost::python::api::object_item>(const A0 &,const A1 &)' 1> with 1> [ 1> A0=boost::python::api::object_item, 1> A1=boost::python::api::object_item 1> ] 1> C:\Program Files\boost_1_42_0\boost/tuple/detail/tuple_basic.hpp(802): or 'boost::tuples::tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9> boost::tuples::make_tuple<boost::python::api::object_item,boost::python::api::object_item>(const T0 &,const T1 &)' [found using argument-dependent lookup] 1> with 1> [ 1> T0=boost::python::api::proxy<boost::python::api::item_policies>, 1> T1=boost::python::api::proxy<boost::python::api::item_policies>, 1> T2=boost::tuples::null_type, 1> T3=boost::tuples::null_type, 1> T4=boost::tuples::null_type, 1> T5=boost::tuples::null_type, 1> T6=boost::tuples::null_type, 1> T7=boost::tuples::null_type, 1> T8=boost::tuples::null_type, 1> T9=boost::tuples::null_type 1> ] Is this a bug in boost::python, or am I doing something wrong? How can I get the above program to compile?

    Read the article

  • A mysterious compilation error: cannot convert from 'const boost::shared_ptr<T>' to 'const boost::shared_ptr<T>'

    - by Stephane Rolland
    I wanted to protect the access to a log file that I use for multithreaded logging with boostlog library. I tried this stream class class ThreadSafeStream { public: template <typename TInput> const ThreadSafeStream& operator<< (const TInput &tInput) const { // some thread safe file access return *this; } }; using it this way (text_sink is a boostlog object): //... m_spSink.reset(new text_sink); text_sink::locked_backend_ptr pBackend = m_spSink->locked_backend(); const boost::shared_ptr< ThreadSafeStream >& spFileStream = boost::make_shared<ThreadSafeStream>(); pBackend->add_stream(spFileStream); // this causes the compilation error and I get this mysterious error: cannot convert from 'const boost::shared_ptr<T>' to 'const boost::shared_ptr<T>' the whole compile error: Log.cpp(79): error C2664: 'boost::log2_mt_nt5::sinks::basic_text_ostream_backend<CharT>::add_stream' : cannot convert parameter 1 from 'const boost::shared_ptr<T>' to 'const boost::shared_ptr<T> &' 1> with 1> [ 1> CharT=char 1> ] 1> and 1> [ 1> T=ThreadSafeStream 1> ] 1> and 1> [ 1> T=std::basic_ostream<char,std::char_traits<char>> 1> ] 1> Reason: cannot convert from 'const boost::shared_ptr<T>' to 'const boost::shared_ptr<T>' 1> with 1> [ 1> T=ThreadSafeStream 1> ] 1> and 1> [ 1> T=std::basic_ostream<char,std::char_traits<char>> 1> ] 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called I suspect that I am not well defining the operator<<()... but I don't find what is wrong.

    Read the article

  • Generate n-dimensional random numbers in Python

    - by Magsol
    I'm trying to generate random numbers from a gaussian distribution. Python has the very useful random.gauss() method, but this is only a one-dimensional random variable. How could I programmatically generate random numbers from this distribution in n-dimensions? For example, in two dimensions, the return value of this method is essentially distance from the mean, so I would still need (x,y) coordinates to determine an actual data point. I suppose I could generate two more random numbers, but I'm not sure how to set up the constraints. I appreciate any insights. Thanks!

    Read the article

  • How do functional languages handle random numbers?

    - by Electric Coffee
    What I mean about that is that in nearly every tutorial I've read about functional languages, is that one of the great things about functions, is that if you call a function with the same parameters twice, you'll always end up with the same result. How on earth do you then make a function that takes a seed as a parameter, and then returns a random number based on that seed? I mean this would seem to go against one of the things that are so good about functions, right? Or am I completely missing something here?

    Read the article

  • Compilation error when using boost serialization library

    - by Shakir
    I have been struggling with this error for a long time. The following is my code snippet. //This is the header file template<typename TElem> class ArrayList { public: /** An accessible typedef for the elements in the array. */ typedef TElem Elem; friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & ptr_; ar & size_; ar & cap_; } Elem *ptr_; // the stored or aliased array index_t size_; // number of active objects index_t cap_; // allocated size of the array; -1 if alias }; template <typename TElem> class gps_position { public: typedef TElem Elem; friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & degrees; ar & minutes; ar & seconds; } private: Elem degrees; index_t minutes; index_t seconds; }; // This is the .cc file #include #include #include #include #include #include #include #include #include "arraylist.h" int main() { // create and open a character archive for output std::ofstream ofs("filename"); // create class instance // gps_position<int> g(35.65, 59, 24.567f); gps_position<float> g; // save data to archive { boost::archive::text_oarchive oa(ofs); // write class instance to archive //oa << g; // archive and stream closed when destructors are called } // ... some time later restore the class instance to its orginal state /* gps_position<int> newg; { // create and open an archive for input std::ifstream ifs("filename"); boost::archive::text_iarchive ia(ifs); // read class state from archive ia >> newg; // archive and stream closed when destructors are called }*/ ArrayList<float> a1; ArrayList<int> a2; a1.Init(22); a2.Init(21); // a1.Resize(30); // a1.Resize(12); // a1.Resize(22); // a2.Resize(22); a1[21] = 99.0; a1[20] = 88.0; for (index_t i = 0; i < a1.size(); i++) { a1[i] = i; a1[i]++; } std::ofstream s("test.txt"); { boost::archive::text_oarchive oa(s); oa << a1; } return 0; } The following is the compilation error i get. In file included from /usr/include/boost/serialization/split_member.hpp:23, from /usr/include/boost/serialization/nvp.hpp:33, from /usr/include/boost/serialization/serialization.hpp:17, from /usr/include/boost/archive/detail/oserializer.hpp:61, from /usr/include/boost/archive/detail/interface_oarchive.hpp:24, from /usr/include/boost/archive/detail/common_oarchive.hpp:20, from /usr/include/boost/archive/basic_text_oarchive.hpp:32, from /usr/include/boost/archive/text_oarchive.hpp:31, from demo.cc:4: /usr/include/boost/serialization/access.hpp: In static member function ‘static void boost::serialization::access::serialize(Archive&, T&, unsigned int) [with Archive = boost::archive::text_oarchive, T = float]’: /usr/include/boost/serialization/serialization.hpp:74: instantiated from ‘void boost::serialization::serialize(Archive&, T&, unsigned int) [with Archive = boost::archive::text_oarchive, T = float]’ /usr/include/boost/serialization/serialization.hpp:133: instantiated from ‘void boost::serialization::serialize_adl(Archive&, T&, unsigned int) [with Archive = boost::archive::text_oarchive, T = float]’ /usr/include/boost/archive/detail/oserializer.hpp:140: instantiated from ‘void boost::archive::detail::oserializer<Archive, T>::save_object_data(boost::archive::detail::basic_oarchive&, const void*) const [with Archive = boost::archive::text_oarchive, T = float]’ demo.cc:105: instantiated from here /usr/include/boost/serialization/access.hpp:109: error: request for member ‘serialize’ in ‘t’, which is of non-class type ‘float’ Please help me out.

    Read the article

  • How to obtain a random sub-datatable from another data table

    - by developerit
    Introduction In this article, I’ll show how to get a random subset of data from a DataTable. This is useful when you already have queries that are filtered correctly but returns all the rows. Analysis I came across this situation when I wanted to display a random tag cloud. I already had the query to get the keywords ordered by number of clicks and I wanted to created a tag cloud. Tags that are the most popular should have more chance to get picked and should be displayed larger than less popular ones. Implementation In this code snippet, there is everything you need. ' Min size, in pixel for the tag Private Const MIN_FONT_SIZE As Integer = 9 ' Max size, in pixel for the tag Private Const MAX_FONT_SIZE As Integer = 14 ' Basic function that retreives Tags from a DataBase Public Shared Function GetTags() As MediasTagsDataTable ' Simple call to the TableAdapter, to get the Tags ordered by number of clicks Dim dt As MediasTagsDataTable = taMediasTags.GetDataValide ' If the query returned no result, return an empty DataTable If dt Is Nothing OrElse dt.Rows.Count < 1 Then Return New MediasTagsDataTable End If ' Set the font-size of the group of data ' We are dividing our results into sub set, according to their number of clicks ' Example: 10 results -> [0,2] will get font size 9, [3,5] will get font size 10, [6,8] wil get 11, ... ' This is the number of elements in one group Dim groupLenth As Integer = CType(Math.Floor(dt.Rows.Count / (MAX_FONT_SIZE - MIN_FONT_SIZE)), Integer) ' Counter of elements in the same group Dim counter As Integer = 0 ' Counter of groups Dim groupCounter As Integer = 0 ' Loop througt the list For Each row As MediasTagsRow In dt ' Set the font-size in a custom column row.c_FontSize = MIN_FONT_SIZE + groupCounter ' Increment the counter counter += 1 ' If the group counter is less than the counter If groupLenth <= counter Then ' Start a new group counter = 0 groupCounter += 1 End If Next ' Return the new DataTable with font-size Return dt End Function ' Function that generate the random sub set Public Shared Function GetRandomSampleTags(ByVal KeyCount As Integer) As MediasTagsDataTable ' Get the data Dim dt As MediasTagsDataTable = GetTags() ' Create a new DataTable that will contains the random set Dim rep As MediasTagsDataTable = New MediasTagsDataTable ' Count the number of row in the new DataTable Dim count As Integer = 0 ' Random number generator Dim rand As New Random() While count < KeyCount Randomize() ' Pick a random row Dim r As Integer = rand.Next(0, dt.Rows.Count - 1) Dim tmpRow As MediasTagsRow = dt(r) ' Import it into the new DataTable rep.ImportRow(tmpRow) ' Remove it from the old one, to be sure not to pick it again dt.Rows.RemoveAt(r) ' Increment the counter count += 1 End While ' Return the new sub set Return rep End Function Pro’s This method is good because it doesn’t require much work to get it work fast. It is a good concept when you are working with small tables, let says less than 100 records. Con’s If you have more than 100 records, out of memory exception may occur since we are coping and duplicating rows. I would consider using a stored procedure instead.

    Read the article

  • boost::asio::async_read_until problem

    - by user368831
    I'm trying to modify the echo server example from boost asio and I'm running into problem when I try to use boost::asio::async_read_until. Here's the code: #include <cstdlib> #include <iostream> #include <boost/bind.hpp> #include <boost/asio.hpp> using boost::asio::ip::tcp; class session { public: session(boost::asio::io_service& io_service) : socket_(io_service) { } tcp::socket& socket() { return socket_; } void start() { std::cout<<"starting"<<std::endl; boost::asio::async_read_until(socket_, boost::asio::buffer(data_, max_length), ' ', boost::bind(&session::handle_read, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); } void handle_read(const boost::system::error_code& error, size_t bytes_transferred) { std::cout<<"handling read"<<std::endl; if (!error) { boost::asio::async_write(socket_, boost::asio::buffer(data_, bytes_transferred), boost::bind(&session::handle_write, this, boost::asio::placeholders::error)); } else { delete this; } } void handle_write(const boost::system::error_code& error) { if (!error) { /* socket_.async_read_some(boost::asio::buffer(data_, max_length), boost::bind(&session::handle_read, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); */ } else { delete this; } } private: tcp::socket socket_; enum { max_length = 1024 }; char data_[max_length]; }; class server { public: server(boost::asio::io_service& io_service, short port) : io_service_(io_service), acceptor_(io_service, tcp::endpoint(tcp::v4(), port)) { session* new_session = new session(io_service_); acceptor_.async_accept(new_session->socket(), boost::bind(&server::handle_accept, this, new_session, boost::asio::placeholders::error)); } void handle_accept(session* new_session, const boost::system::error_code& error) { if (!error) { new_session->start(); new_session = new session(io_service_); acceptor_.async_accept(new_session->socket(), boost::bind(&server::handle_accept, this, new_session, boost::asio::placeholders::error)); } else { delete new_session; } } private: boost::asio::io_service& io_service_; tcp::acceptor acceptor_; }; int main(int argc, char* argv[]) { try { if (argc != 2) { std::cerr << "Usage: async_tcp_echo_server <port>\n"; return 1; } boost::asio::io_service io_service; using namespace std; // For atoi. server s(io_service, atoi(argv[1])); io_service.run(); } catch (std::exception& e) { std::cerr << "Exception: " << e.what() << "\n"; } return 0; } The problem is when I try to compile I get this weird error: server.cpp: In member function ‘void session::start()’: server.cpp:27: error: no matching function for call to ‘async_read_until(boost::asio::basic_stream_socket &, boost::asio::mutable_buffers_1, char, boost::_bi::bind_t, boost::_bi::list3, boost::arg<1 ()(), boost::arg<2 ()() )’ Can someone please explain what's going on? From what I can tell the arguments to async_read_until are correct. Thanks!

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >