VectorResultType
};
+
+
template <class Dist>
struct ParamTypeHelper {
using ParamT = typename Dist::param_type;
static_assert(std::is_same<ResultT, typename ParamT::distribution_type::result_type>::value, "");
static ParamT Create(const uint8_t* data, size_t size, bool &OK) {
- if constexpr (std::is_constructible<ParamT, ResultT*, ResultT*, ResultT*>::value)
- return CreateVectorResult(data, size, OK);
- else if constexpr (std::is_constructible<ParamT, double*, double*>::value)
- return CreateVectorDouble(data, size, OK);
- else
- return CreateDefault(data, size, OK);
+ constexpr bool select_vector_result = std::is_constructible<ParamT, ResultT*, ResultT*, ResultT*>::value;
+ constexpr bool select_vector_double = std::is_constructible<ParamT, double*, double*>::value;
+ constexpr int selector = select_vector_result ? 0 : (select_vector_double ? 1 : 2);
+ return DispatchAndCreate(std::integral_constant<int, selector>{}, data, size, OK);
+
}
+ static ParamT DispatchAndCreate(std::integral_constant<int, 0>, const uint8_t *data, size_t size, bool &OK) {
+ return CreateVectorResult(data, size, OK);
+ }
+ static ParamT DispatchAndCreate(std::integral_constant<int, 1>, const uint8_t *data, size_t size, bool &OK) {
+ return CreateVectorDouble(data, size, OK);
+ }
+ static ParamT DispatchAndCreate(std::integral_constant<int, 2>, const uint8_t *data, size_t size, bool &OK) {
+ return CreateDefault(data, size, OK);
+ }
-static ParamT
+static ParamT
CreateVectorResult(const uint8_t *data, size_t size, bool &OK) {
auto Input = GetValues<ResultT>(data, size);
OK = false;