types: add std::data analogue
This commit is contained in:
parent
a73fb9307c
commit
e5dd121ece
32
types.hpp
32
types.hpp
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user