diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e89cc4..b59e19f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -358,6 +358,7 @@ target_link_libraries(rhubarb-time # ... rhubarb-tools add_library(rhubarb-tools + src/tools/array.h src/tools/EnumConverter.h src/tools/exceptions.cpp src/tools/exceptions.h diff --git a/src/tools/array.h b/src/tools/array.h new file mode 100644 index 0000000..91bba56 --- /dev/null +++ b/src/tools/array.h @@ -0,0 +1,41 @@ +#pragma once + +#include + +// This file contains an implementation of std::experimental::make_array. + +namespace details { + template + struct negation : std::integral_constant {}; + + template struct is_ref_wrapper : std::false_type {}; + template struct is_ref_wrapper> : std::true_type {}; + + template + using not_ref_wrapper = negation>>; + + template struct conjunction : std::true_type { }; + template struct conjunction : B1 { }; + template + struct conjunction + : std::conditional_t, B1> {}; + + template + constexpr bool conjunction_v = conjunction::value; + + template struct return_type_helper { using type = D; }; + template + struct return_type_helper : std::common_type { + static_assert(conjunction_v...>, + "Types cannot contain reference_wrappers when D is void"); + }; + + template + using return_type = std::array::type, + sizeof...(Types)>; +} + +template < class D = void, class... Types> +constexpr details::return_type make_array(Types&&... t) { + return {std::forward(t)...}; +} \ No newline at end of file