Boost logo

Boost Users :

Subject: [Boost-users] [mpl] Why no wrapper for pointers as non-type template parameters?
From: Philipp Moeller (philipp.moeller_at_[hidden])
Date: 2012-05-04 16:24:42


I'm a little surprised that the MPL does not offer a wrapper for
pointers as constants. They sometimes come in handy to specify lists to
different callable objects.

Something along the lines of:

template<typename T, T N>
struct ptr_wrap {
  static const T value;
  typedef ptr_wrap<T, N> type;
  typedef T value_type;
};

template<typename T, T N>
typename ptr_wrap<T, N>::value_type const ptr_wrap<T, N>::value = N;

already does the job for me, but it could possibly be enhanced with a
helper to use the correct syntax for pointers to member.

Could this be an addition to the library or is there a better way?

Cheers,
Philipp Moeller


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