Browse Source

Improved ReadType-based concepts

interpolate
Michael Uleysky 1 year ago
parent
commit
8a1cf03804
  1. 34
      include/traits.h

34
include/traits.h

@ -3,6 +3,7 @@
#include <concepts> #include <concepts>
class BaseParameters; class BaseParameters;
using michlib::real; using michlib::real;
template<class T> template<class T>
@ -82,6 +83,11 @@ template<class D> struct GetReadType_<D, false, true>
using type = decltype(D().Read(MString(), 0)); using type = decltype(D().Read(MString(), 0));
}; };
template<class D> struct GetReadType_<D, false, false>
{
using type = std::decay_t<D>;
};
template<class T> template<class T>
concept HaveDisable = requires(T t) { concept HaveDisable = requires(T t) {
{ {
@ -124,19 +130,39 @@ template<class D> using ReadType = internal::GetReadType_<D, ReadPSupported<D>,
template<class T> template<class T>
concept ReadIsGrid = requires { concept ReadIsGrid = requires {
{ {
ReadType<T>().XStep() std::declval<ReadType<T>>().XStep()
} -> std::convertible_to<real>; } -> std::convertible_to<real>;
{ {
ReadType<T>().YStep() std::declval<ReadType<T>>().YStep()
} -> std::convertible_to<real>; } -> std::convertible_to<real>;
}; };
template<class T> template<class T>
concept ReadIs2DGeoRectArray = requires { concept ReadIs2DGeoRectArray = requires {
{ {
ReadType<T>().Ix2Lon(0) std::declval<ReadType<T>>().Ix2Lon(0)
} -> std::convertible_to<real>;
{
std::declval<ReadType<T>>().Iy2Lat(0)
} -> std::convertible_to<real>;
};
template<class T>
concept ReadIs2DGeoArray = requires {
{
std::declval<ReadType<T>>().Lon(0, 0)
} -> std::convertible_to<real>;
{
std::declval<ReadType<T>>().Lat(0, 0)
} -> std::convertible_to<real>;
};
template<class T>
concept ReadIs1DGeoArray = requires {
{
std::declval<ReadType<T>>().Lon(0)
} -> std::convertible_to<real>; } -> std::convertible_to<real>;
{ {
ReadType<T>().Iy2Lat(0) std::declval<ReadType<T>>().Lat(0)
} -> std::convertible_to<real>; } -> std::convertible_to<real>;
}; };

Loading…
Cancel
Save