enable_if operator+ exists
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?
Zachary Turner wrote:
How would I implement the operator_plus_exists class? Such a traits have been added to type_traits, check the trunk or the vault.
-- ___________________________________________ Joel Falcou - Assistant Professor PARALL Team - LRI - Universite Paris Sud XI Tel : (+33)1 69 15 66 35
How would I implement the operator_plus_exists class?
Such a traits have been added to type_traits, check the trunk or the vault.
I am working on adding such traits for comparison operators (operator<, operator>...) You can have a look at a working draft here: https://svn.boost.org/trac/boost/browser/sandbox/type_traits Look at is_less_comparable.hpp Frédéric
2009/12/6 Frédéric Bron <frederic.bron@m4x.org>
How would I implement the operator_plus_exists class?
Such a traits have been added to type_traits, check the trunk or the vault.
I am working on adding such traits for comparison operators (operator<, operator>...) You can have a look at a working draft here: https://svn.boost.org/trac/boost/browser/sandbox/type_traits Look at is_less_comparable.hpp
Thanks, for the record I actually finally got mine working. I figured out at least 5 ways that *should* have worked, but MSVC wouldn't compile it. But I did hit upon one that worked, but it's over on the boost dev mailing list now. Zach
participants (3)
-
Frédéric Bron
-
joel falcou
-
Zachary Turner