Added makearray

This commit is contained in:
2021-08-07 00:07:23 +02:00
parent a436aef990
commit faeacdcfbf
3 changed files with 36 additions and 0 deletions

View File

@ -10,6 +10,7 @@ set(headers
src/cpputils.h
src/crc32builder.h
src/delayedconstruction.h
src/makearray.h
src/numberparsing.h
src/refwhenneeded.h
src/strutils.h

View File

@ -1,5 +1,6 @@
HEADERS += \
$$PWD/src/cleanuphelper.h \
$$PWD/src/color_utils.h \
$$PWD/src/cppbitmask.h \
$$PWD/src/cppflags.h \
$$PWD/src/cppmacros.h \
@ -7,9 +8,13 @@ HEADERS += \
$$PWD/src/cppsignal.h \
$$PWD/src/cpptypesafeenum.h \
$$PWD/src/cpputils.h \
$$PWD/src/crc32builder.h \
$$PWD/src/delayedconstruction.h \
$$PWD/src/makearray.h \
$$PWD/src/numberparsing.h \
$$PWD/src/refwhenneeded.h \
$$PWD/src/strutils.h
SOURCES += \
$$PWD/src/color_utils.cpp \
$$PWD/src/strutils.cpp

30
src/makearray.h Normal file
View File

@ -0,0 +1,30 @@
#pragma once
// system includes
#include <array>
namespace goe {
namespace details {
template<class> struct is_ref_wrapper : std::false_type {};
template<class T> struct is_ref_wrapper<std::reference_wrapper<T>> : std::true_type {};
template<class T>
using not_ref_wrapper = std::negation<is_ref_wrapper<std::decay_t<T>>>;
template <class D, class...> struct return_type_helper { using type = D; };
template <class... Types>
struct return_type_helper<void, Types...> : std::common_type<Types...> {
//static_assert(std::conjunction_v<not_ref_wrapper<Types>...>,
// "Types cannot contain reference_wrappers when D is void");
};
template <class D, class... Types>
using return_type = std::array<typename return_type_helper<D, Types...>::type,
sizeof...(Types)>;
} // namespace details
template < class D = void, class... Types>
constexpr details::return_type<D, Types...> make_array(Types&&... t) {
return {std::forward<Types>(t)... };
}
} // namespace goe