What is the differences between these classes? Specifically, these member functions with enable_if
.
/// Alias of std::enable_if...
template <bool B, typename T = void>
using Enable_if = typename std::enable_if<B, T>::type;
template<typename T, std::size_t N>
class A {
...
template <std::size_t NN = N,
typename = Enable_if<NN == 2>>
Some_Return_Type
method(param1, param2)
{}
template <std::size_t NN = N,
typename = Enable_if<NN == 1>>
Some_Return_Type
method(param1)
{}
};
template<typename T, std::size_t N>
class B {
...
Enable_if<N == 2, Some_Return_Type>
method(param1, param2)
{}
Enable_if<N == 1, Some_Return_Type>
method(param1)
{}
};
What is the correct way to use enable_if
in the case I have:
- At least 2 methods that differs only in their arguments and they have the same name but just one of them must be "active" (if
N == 1
one of them, ifN == 2
the other). - Only one method that will be active if
N == 0
and not active in other cases.
I would like to get something like:
Obj<int, 2> obj2;
Obj<int, 0> obj0;
Obj<int, 1> obj1;
if I write in the IDE obj0.
it should show only methods of:
N == 0
;- for
obj1.
, onlyN == 1
- ...