Boost logo

Boost Users :

Subject: [Boost-users] enable_if operator+ exists
From: Zachary Turner (divisortheory_at_[hidden])
Date: 2009-12-06 01:11:57


Is there a way to use enable_if so that one specialization gets selected if
operator+ exists between two types, and another specialization if operator+
does not exist? For example:

template<class A, class B, boost::enable_if<operator_plus_exists<A,B>
>::type* dummy = 0>
void operator()(const A& a, const B& b)
{
   std::cout << "a + b = " << (a + b) << std::endl;
}

template<class A, class B, boost::disable_if<operator_plus_exists<A,B>
>::type* dummy = 0>
void operator()(const A& a, const B& b)
{
}

How would I implement the operator_plus_exists class?



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