|
Boost Users : |
Subject: [Boost-users] enable_if for class members
From: Christopher Jefferson (chris_at_[hidden])
Date: 2009-01-30 09:21:12
In a class, I want to have one member function which has different
implementations depending on one of the template parameters. I tried
to use enable_if
template<bool b>
struct foo
{
typename boost::enable_if_c<b, int>::type
get_val( )
{ return 2; }
typename boost::disable_if_c<b, int>::type
get_val()
{ return 3; }
};
But when I use foo in code, it doesn't work, complaning that:
error: no type named 'type' in 'struct boost::enable_if_c<true, int>'
Am I not using enable_if in the correct way? Is there any easy way to
do waht I'm trying to do? I used to do this by declaring an inner
class and overloading that, but then it is necessary to pass in the
class and the code looks very messy.
Thanks,
Chris
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