mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-02-04 21:33:56 +00:00
fix make_array (add common type version)
This commit is contained in:
parent
d082fa743b
commit
6f399977b2
2 changed files with 16 additions and 16 deletions
|
@ -19,7 +19,7 @@ namespace testspr {
|
||||||
SPROUT_STATIC_CONSTEXPR int carr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
SPROUT_STATIC_CONSTEXPR int carr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||||
SPROUT_STATIC_CONSTEXPR auto arr1 = sprout::to_array(carr);
|
SPROUT_STATIC_CONSTEXPR auto arr1 = sprout::to_array(carr);
|
||||||
SPROUT_STATIC_CONSTEXPR auto arr2 = sprout::make_array<int>(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
|
SPROUT_STATIC_CONSTEXPR auto arr2 = sprout::make_array<int>(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
|
||||||
SPROUT_STATIC_CONSTEXPR auto arr3 = sprout::make_common_array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
|
SPROUT_STATIC_CONSTEXPR auto arr3 = sprout::make_array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
|
||||||
|
|
||||||
TESTSPR_BOTH_ASSERT(testspr::equal(carr, arr1));
|
TESTSPR_BOTH_ASSERT(testspr::equal(carr, arr1));
|
||||||
TESTSPR_BOTH_ASSERT(testspr::equal(carr, arr2));
|
TESTSPR_BOTH_ASSERT(testspr::equal(carr, arr2));
|
||||||
|
|
|
@ -17,6 +17,11 @@
|
||||||
#include <sprout/type_traits/common_decay.hpp>
|
#include <sprout/type_traits/common_decay.hpp>
|
||||||
|
|
||||||
namespace sprout {
|
namespace sprout {
|
||||||
|
namespace detail {
|
||||||
|
enum make_array_t {
|
||||||
|
make_array_in_common_elements
|
||||||
|
};
|
||||||
|
} // namespace detail
|
||||||
//
|
//
|
||||||
// make_array
|
// make_array
|
||||||
//
|
//
|
||||||
|
@ -25,16 +30,15 @@ namespace sprout {
|
||||||
make_array(Types&&... args) {
|
make_array(Types&&... args) {
|
||||||
return sprout::array<typename std::remove_cv<T>::type, sizeof...(Types)>{{T(SPROUT_FORWARD(Types, args))...}};
|
return sprout::array<typename std::remove_cv<T>::type, sizeof...(Types)>{{T(SPROUT_FORWARD(Types, args))...}};
|
||||||
}
|
}
|
||||||
// !!! OLD:
|
template<sprout::detail::make_array_t = sprout::detail::make_array_in_common_elements, typename... Types>
|
||||||
// template<typename... Types>
|
inline SPROUT_CONSTEXPR sprout::array<typename sprout::common_decay<Types...>::type, sizeof...(Types)>
|
||||||
// inline SPROUT_CONSTEXPR sprout::array<typename sprout::common_decay<Types...>::type, sizeof...(Types)>
|
make_array(Types&&... args) {
|
||||||
// make_array(Types&&... args) {
|
typedef sprout::array<
|
||||||
// typedef sprout::array<
|
typename sprout::common_decay<Types...>::type,
|
||||||
// typename sprout::common_decay<Types...>::type,
|
sizeof...(Types)
|
||||||
// sizeof...(Types)
|
> type;
|
||||||
// > type;
|
return type{{typename sprout::common_decay<Types...>::type(SPROUT_FORWARD(Types, args))...}};
|
||||||
// return type{{typename sprout::common_decay<Types...>::type(SPROUT_FORWARD(Types, args))...}};
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// make_common_array
|
// make_common_array
|
||||||
|
@ -42,11 +46,7 @@ namespace sprout {
|
||||||
template<typename... Types>
|
template<typename... Types>
|
||||||
inline SPROUT_CONSTEXPR sprout::array<typename sprout::common_decay<Types...>::type, sizeof...(Types)>
|
inline SPROUT_CONSTEXPR sprout::array<typename sprout::common_decay<Types...>::type, sizeof...(Types)>
|
||||||
make_common_array(Types&&... args) {
|
make_common_array(Types&&... args) {
|
||||||
typedef sprout::array<
|
return sprout::make_array(SPROUT_FORWARD(Types, args)...);
|
||||||
typename sprout::common_decay<Types...>::type,
|
|
||||||
sizeof...(Types)
|
|
||||||
> type;
|
|
||||||
return type{{typename sprout::common_decay<Types...>::type(SPROUT_FORWARD(Types, args))...}};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Add table
Reference in a new issue