Boost logo

Boost Users :

From: Nindi (Nindi73_at_[hidden])
Date: 2006-06-25 09:35:30


I have started using Boost recently, and though I should switch my own
variant to the Boost Variant . However I cannot compile the following code

#include<iostream>

#include<vector>

#include<string>

#include<boost/variant.hpp>

std::basic_ostream<char> &operator<<(std::basic_ostream<char>
&theostream,const std::vector<unsigned long> &theVector)

{

for(unsigned long i(0);i<theVector.size();i++)

theostream << theVector[i] << "\n" ;

return theostream;

}

struct TpTemplateVariant {

typedef boost::variant< int,

unsigned long,

double,

bool,

std::string,

std::vector<unsigned long>

> BoostVariant;

};

typedef TpTemplateVariant::BoostVariant Tpvariant;

int main () {

Tpvariant p(5);

std::cout << p;

return 0;

}

The error I get is

error C2679: binary '<<' : no operator found which takes a right-hand
operand of type 'const T5'


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net