vileda
asked on
No match for operator "<<"
Hello,
Im trying to compile boost's variant example which is given in boost web site.
But it gives an error like this
No match for operator "<<" ... ... .... variant_io.hpp
What could be the problem?
Kind regards
Im trying to compile boost's variant example which is given in boost web site.
#include "boost/variant.hpp"
#include <iostream>
class my_visitor : public boost::static_visitor<int>
{
public:
int operator()(int i) const
{
return i;
}
int operator()(const std::string & str) const
{
return str.length();
}
};
int main()
{
boost::variant< int, std::string > u("hello world");
std::cout << u; // output: hello world
int result = boost::apply_visitor( my_visitor(), u );
std::cout << result; // output: 11 (i.e., length of "hello world")
}
But it gives an error like this
No match for operator "<<" ... ... .... variant_io.hpp
What could be the problem?
Kind regards
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
I'm trying to compile it from QNX Momentics Windows version. The include path seems ok and I have only one version.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
HappyCactus$ g++ --version
i686-apple-darwin10-g++-4.
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
anaconda:b HappyCactus$ grep BOOST_LIB_VERSION /usr/local/include/boost/v
// BOOST_LIB_VERSION must be defined to be the same as BOOST_VERSION
#define BOOST_LIB_VERSION "1_44"
anaconda:b HappyCactus$
Check carefully your compilation options and the include path. If you have multiple version of boost, remove all but the most recent. and upgrade boost.