enable_if for function templates

Hi all,
I am trying to enable only two version of a function. The caller may choose
one
of the two versions by specifying a template parameter. I've got two
versions
for the problem, both of them failing the same way.
--------------------------
Version A): integral template parameter
--------------------------
#include <iostream>
#include

Agoston Bejo wrote:
Hi all, I am trying to enable only two version of a function. The caller may choose one
of the two versions by specifying a template parameter. I've got two versions
#include <iostream> #include
#include using namespace std; using namespace boost;
template
enable_if_c f(T t) { cout << 1 << endl; } template
enable_if_c f(T t) { cout << 2 << endl; } int _tmain(int argc, _TCHAR* argv[])
_tmain, _TCHAR ... what are these funny symbols? ;-)
{ f<1>(10); // ERROR f<2>(5.5); // ERROR f<3>(7); // ERROR return 0; }
I'd say enable_if is not the right tool for this situation. Try:
template<int N>
struct f_impl {
template<typename T>
static void execute(T t)
{
cout << "f_impl::execute()" << "\n";
}
};
template

"Agoston Bejo"
Hi all, I am trying to enable only two version of a function. The caller may choose one
of the two versions by specifying a template parameter. I've got two versions
for the problem, both of them failing the same way. template
enable_if_c f(T t) { cout << 1 << endl; }
FWIW enable_if signature is required as follows:
template
participants (3)
-
Agoston Bejo
-
Andy Little
-
Jonathan Turkanis