Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a type-trait to remove top-level cv and reference at once?

I just want to know if there is already one provided by the standard. I know it's easy to make one yourself

// for C++03, use <tr1/type_traits> and std::tr1
#include <type_traits>

template<class T>
struct remove_toplevel{
  typedef typename std::remove_reference<T>::type noref_T;
  typedef typename std::remove_cv<noref_T>::type noref_nocv_T;
  typedef noref_nocv_T type;
};

but I think I forgot something in there or got the order wrong, so it'd be nice to have a prepared one, if one exists.

like image 600
Xeo Avatar asked Jun 05 '11 22:06

Xeo


1 Answers

std::decay, I believe, performs this functionality.

like image 149
Puppy Avatar answered Oct 11 '22 20:10

Puppy