extent: add make_extent call
we use this until template constructor guides are available in our supported compilers
This commit is contained in:
parent
f39f7d7362
commit
bdd2e06044
34
extent.hpp
34
extent.hpp
@ -82,6 +82,32 @@ namespace util {
|
|||||||
extent<S,T> m_target;
|
extent<S,T> m_target;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/// 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>
|
template <size_t S, typename T>
|
||||||
extent_range<S,T>
|
extent_range<S,T>
|
||||||
make_range (extent<S,T> e)
|
make_range (extent<S,T> e)
|
||||||
@ -89,6 +115,8 @@ namespace util {
|
|||||||
return extent_range<S,T> {e};
|
return extent_range<S,T> {e};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// convenience typedefs
|
// convenience typedefs
|
||||||
template <typename T> using extent2 = extent<2,T>;
|
template <typename T> using extent2 = extent<2,T>;
|
||||||
template <typename T> using extent3 = extent<3,T>;
|
template <typename T> using extent3 = extent<3,T>;
|
||||||
@ -98,20 +126,24 @@ namespace util {
|
|||||||
template <size_t S> using extentf = extent<S,float>;
|
template <size_t S> using extentf = extent<S,float>;
|
||||||
template <size_t S> using extentd = extent<S,double>;
|
template <size_t S> using extentd = extent<S,double>;
|
||||||
|
|
||||||
|
|
||||||
typedef extent2<int> extent2i;
|
typedef extent2<int> extent2i;
|
||||||
typedef extent2<unsigned> extent2u;
|
typedef extent2<unsigned> extent2u;
|
||||||
typedef extent2<float> extent2f;
|
typedef extent2<float> extent2f;
|
||||||
typedef extent2<double> extent2d;
|
typedef extent2<double> extent2d;
|
||||||
|
|
||||||
|
|
||||||
typedef extent3<unsigned> extent3u;
|
typedef extent3<unsigned> extent3u;
|
||||||
typedef extent3<float> extent3f;
|
typedef extent3<float> extent3f;
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
template <typename T> using extent_range2 = extent_range<2,T>;
|
template <typename T> using extent_range2 = extent_range<2,T>;
|
||||||
template <typename T> using extent_range3 = extent_range<3,T>;
|
template <typename T> using extent_range3 = extent_range<3,T>;
|
||||||
|
|
||||||
|
|
||||||
using extent_range2u = extent_range2<typename extent2u::value_type>;
|
using extent_range2u = extent_range2<typename extent2u::value_type>;
|
||||||
using extent_range2i = extent_range2<typename extent2i::value_type>;
|
using extent_range2i = extent_range2<typename extent2i::value_type>;
|
||||||
|
|
||||||
using extent_range3u = extent_range2<typename extent3u::value_type>;
|
using extent_range3u = extent_range2<typename extent3u::value_type>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user