Boost logo

Boost Users :

Subject: Re: [Boost-users] [enable_if] Compile Time Member Overloading
From: Nathan Crookston (nathan.crookston_at_[hidden])
Date: 2012-11-19 12:16:16


Christian Henning wrote:

> One more thing do I actually need to build a mpl::bool_ out of the
> is_same function?
>

enable_if requres an integral constant wrapper. There is a variant called
enable_if_c which allows you to skip that in this case (automatically wraps
it, I believe, like mpl::vector_c):

#include <boost/mpl/and.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/utility/enable_if.hpp>

using namespace boost;

struct foo
{
  void bla()
  {
    read_data_24<int, int>();
  }

  template< typename T1, typename T2>
  void read_data_24(typename enable_if_c< is_same< T1, T2 >::value>::type*
= 0)
  {
      int i = 9;
  }
};

int main(int argc, char* argv[])
{
    return 0;
}

HTH,
Nate



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