coord/ops: move make_coord higher for visibility

latter code may require make_coord it should be above most of the
operations.
This commit is contained in:
Danny Robson 2017-08-28 12:58:18 +10:00
parent c4e367e648
commit c0df6bf8a2

View File

@ -111,6 +111,50 @@ namespace util {
} }
///////////////////////////////////////////////////////////////////////////
/// 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 \
> \
constexpr 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
template <
template <std::size_t,typename> class K,
typename ...Args
>
constexpr auto
make_coord (Args &&...args)
{
using T = std::common_type_t<Args...>;
return K<sizeof...(Args),T> { std::forward<Args> (args)... };
}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// vector operators // vector operators
#define ELEMENT_OP(OP) \ #define ELEMENT_OP(OP) \
@ -1203,38 +1247,6 @@ namespace util {
static_assert (I < S); static_assert (I < S);
return k[I]; 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 \
> \
constexpr 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
} }