@@ -652,23 +652,33 @@ enum InitKind {
652
652
VectorResultType
653
653
};
654
654
655
+
656
+
655
657
template <class Dist >
656
658
struct ParamTypeHelper {
657
659
using ParamT = typename Dist::param_type;
658
660
using ResultT = typename Dist::result_type;
659
661
static_assert (std::is_same<ResultT, typename ParamT::distribution_type::result_type>::value, " " );
660
662
static ParamT Create (const uint8_t * data, size_t size, bool &OK) {
661
663
662
- if constexpr (std::is_constructible<ParamT, ResultT*, ResultT*, ResultT*>::value)
663
- return CreateVectorResult (data, size, OK);
664
- else if constexpr (std::is_constructible<ParamT, double *, double *>::value)
665
- return CreateVectorDouble (data, size, OK);
666
- else
667
- return CreateDefault (data, size, OK);
664
+ constexpr bool select_vector_result = std::is_constructible<ParamT, ResultT*, ResultT*, ResultT*>::value;
665
+ constexpr bool select_vector_double = std::is_constructible<ParamT, double *, double *>::value;
666
+ constexpr int selector = select_vector_result ? 0 : (select_vector_double ? 1 : 2 );
667
+ return DispatchAndCreate (std::integral_constant<int , selector>{}, data, size, OK);
668
+
668
669
}
669
670
671
+ static ParamT DispatchAndCreate (std::integral_constant<int , 0 >, const uint8_t *data, size_t size, bool &OK) {
672
+ return CreateVectorResult (data, size, OK);
673
+ }
674
+ static ParamT DispatchAndCreate (std::integral_constant<int , 1 >, const uint8_t *data, size_t size, bool &OK) {
675
+ return CreateVectorDouble (data, size, OK);
676
+ }
677
+ static ParamT DispatchAndCreate (std::integral_constant<int , 2 >, const uint8_t *data, size_t size, bool &OK) {
678
+ return CreateDefault (data, size, OK);
679
+ }
670
680
671
- static ParamT
681
+ static ParamT
672
682
CreateVectorResult (const uint8_t *data, size_t size, bool &OK) {
673
683
auto Input = GetValues<ResultT>(data, size);
674
684
OK = false ;
0 commit comments