Boost logo

Boost Users :

Subject: [Boost-users] OT: Why can't I insert a vector of int
From: Patrick Horgan (phorgan1_at_[hidden])
Date: 2011-03-28 14:36:27


I simplified this as much as possible and it turned into a template
question, and not a boost question, but I hope that someone here will
take a second and answer it anyway. I don't know of another mailing
list with the expertise of this one in templates. In the below, the
inserter for vector<int> is never used, instead, since the vector<int>
is a type, it matches the simpler inserter for T. How can I make it
work the way I want it to?

#include <iostream>
#include <vector>

struct theclass
{
     template<typename T>
     void operator<<(const T& t){ std::cout << "Got a T\n"; }
     template<typename T>
     void operator<<(std::vector<const T> t){ std::cout << "Got a vector
of T\n"; }
};

int
main()
{
     std::vector<int> vi;
     int i;
     theclass f;
     f << i;
     f << vi;
}


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