Template with constant expression: error C2975 with VC++2008
- by Arman
Hello, I am trying to use elements of meta programming, but hit the wall with the first trial.
I would like to have a comparator structure which can be used as following:
intersect_by<ID>(L1.data, L2.data, "By ID: ");
intersect_by<IDf>(L1.data, L2.data, "By IDf: ");
Where:
struct ID{};// Tag used for original IDs
struct IDf{};// Tag used for the file position
//following Boost.MultiIndex examples
template<typename Tag,typename MultiIndexContainer>
void intersect_by(
const MultiIndexContainer& L1,const MultiIndexContainer& L2,std::string msg,
Tag* =0 /* fixes a MSVC++ 6.0 bug with implicit template function parms /
)
{
/ obtain a reference to the index tagged by Tag */
const typename boost::multi_index::index<MultiIndexContainer,Tag>::type& L1_ID_index=
get<Tag>(L1);
const typename boost::multi_index::index<MultiIndexContainer,Tag>::type& L2_ID_index=
get<Tag>(L2);
std::set_intersection(
L1_ID_index.begin(),
L1_ID_index.end(),
L2_ID_index.begin(),
L2_ID_index.end(),
std::inserter(s, s.begin()), strComparator() // Here I get the C2975 error
);
}
template<int N> struct strComparator;
template<>
struct strComparator<0>{
bool operator () (const particleID& id1, const particleID& id2) const
{
return id1.ID
struct strComparator<1{
bool operator () (const particleID& id1, const particleID& id2) const
{
return id1.IDf
};
What I am missing?
kind regards
Arman.