types: add std::data analogue

This commit is contained in:
Danny Robson 2015-11-05 13:17:59 +11:00
parent a73fb9307c
commit e5dd121ece

View File

@ -36,7 +36,37 @@ elems (const T &t)
{ return t.size (); }
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// analogue of std::data for use until we get proper c++17 support
namespace util {
template <typename T>
auto
data (T &t)
{ return t.data (); }
//-------------------------------------------------------------------------
template <typename T>
auto
data (const T &t)
{ return t.data (); }
//-------------------------------------------------------------------------
template <typename T, size_t N>
constexpr T*
data (T (&t)[N])
{ return &t[0]; }
//-------------------------------------------------------------------------
template <typename T, size_t N>
constexpr const T*
data (const T (&t)[N])
{ return &t[0]; }
}
///////////////////////////////////////////////////////////////////////////////
template <class T>
T
first (T a) {