coord: define make_klass for all coordinate types

This commit is contained in:
Danny Robson 2017-07-28 16:08:59 +10:00
parent e5090ff916
commit 2fad1715cf
2 changed files with 32 additions and 24 deletions

View File

@ -931,6 +931,38 @@ namespace util {
static_assert (I < S);
return k[I];
};
/// create a coord from supplied arguments, optionally specifying the
/// underlying type.
///
/// much like experimental::make_array we use a void type to signal we
/// need to deduce the underlying type.
#define MAKE_COORD(KLASS) \
template < \
typename _T = void, \
typename ...Args \
> \
auto \
make_##KLASS (Args &&...args) \
{ \
using T = std::conditional_t< \
std::is_void_v<_T>, \
std::common_type_t<Args...>, \
_T \
>; \
\
return KLASS<sizeof...(Args),T> { \
std::forward<Args> (args)... \
}; \
}
MAKE_COORD(extent)
MAKE_COORD(point)
MAKE_COORD(colour)
MAKE_COORD(vector)
#undef MAKE_COORD
}

View File

@ -83,30 +83,6 @@ namespace util {
};
/// create an extent from supplied arguments, optionally specifying the
/// underlying type.
///
/// much like experimental::make_array we use a void type to signal we
/// need to deduce the underlying type.
template <
typename _T = void,
typename ...Args
>
auto
make_extent (Args &&...args)
{
using T = std::conditional_t<
std::is_void_v<_T>,
std::common_type_t<Args...>,
_T
>;
return extent<sizeof...(Args),T> {
std::forward<Args> (args)...
};
}
///////////////////////////////////////////////////////////////////////////
template <size_t S, typename T>
extent_range<S,T>