2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
2016-02-25 09:48:28 +00:00
|
|
|
Copyright (c) 2011-2016 Bolero MURAKAMI
|
2013-08-08 09:54:33 +00:00
|
|
|
https://github.com/bolero-MURAKAMI/Sprout
|
|
|
|
|
|
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
=============================================================================*/
|
2012-06-22 10:14:21 +00:00
|
|
|
#ifndef SPROUT_ARRAY_MAKE_ARRAY_HPP
|
|
|
|
#define SPROUT_ARRAY_MAKE_ARRAY_HPP
|
|
|
|
|
|
|
|
#include <type_traits>
|
|
|
|
#include <sprout/config.hpp>
|
2014-04-30 07:30:26 +00:00
|
|
|
#include <sprout/workaround/std/cstddef.hpp>
|
2013-04-06 04:06:51 +00:00
|
|
|
#include <sprout/index_tuple/metafunction.hpp>
|
2012-06-22 10:14:21 +00:00
|
|
|
#include <sprout/array/array.hpp>
|
|
|
|
#include <sprout/utility/forward.hpp>
|
2013-03-21 13:11:40 +00:00
|
|
|
#include <sprout/type_traits/common_decay.hpp>
|
2012-06-22 10:14:21 +00:00
|
|
|
|
|
|
|
namespace sprout {
|
2014-04-15 03:31:13 +00:00
|
|
|
namespace detail {
|
|
|
|
enum make_array_t {
|
|
|
|
make_array_in_common_elements
|
|
|
|
};
|
|
|
|
} // namespace detail
|
2012-06-22 10:14:21 +00:00
|
|
|
//
|
|
|
|
// make_array
|
|
|
|
//
|
|
|
|
template<typename T, typename... Types>
|
2013-10-25 15:32:36 +00:00
|
|
|
inline SPROUT_CONSTEXPR sprout::array<typename std::remove_cv<T>::type, sizeof...(Types)>
|
2012-10-04 16:53:39 +00:00
|
|
|
make_array(Types&&... args) {
|
2014-02-22 07:32:51 +00:00
|
|
|
return sprout::array<typename std::remove_cv<T>::type, sizeof...(Types)>{{T(SPROUT_FORWARD(Types, args))...}};
|
2012-06-22 10:14:21 +00:00
|
|
|
}
|
2016-04-03 12:00:55 +00:00
|
|
|
template<typename T, std::size_t N, typename... Types>
|
|
|
|
inline SPROUT_CONSTEXPR sprout::array<typename std::remove_cv<T>::type, N>
|
|
|
|
make_array(Types&&... args) {
|
|
|
|
return sprout::array<typename std::remove_cv<T>::type, N>{{T(SPROUT_FORWARD(Types, args))...}};
|
|
|
|
}
|
2014-04-15 03:56:28 +00:00
|
|
|
template<sprout::detail::make_array_t = sprout::detail::make_array_in_common_elements, typename... Types>
|
2014-04-15 03:31:13 +00:00
|
|
|
inline SPROUT_CONSTEXPR sprout::array<typename sprout::common_decay<Types...>::type, sizeof...(Types)>
|
|
|
|
make_array(Types&&... args) {
|
2014-04-15 04:37:38 +00:00
|
|
|
typedef typename sprout::common_decay<Types...>::type value_type;
|
|
|
|
typedef sprout::array<value_type, sizeof...(Types)> type;
|
|
|
|
return type{{value_type(SPROUT_FORWARD(Types, args))...}};
|
|
|
|
}
|
2016-04-03 12:00:55 +00:00
|
|
|
template<std::size_t N, sprout::detail::make_array_t = sprout::detail::make_array_in_common_elements, typename... Types>
|
|
|
|
inline SPROUT_CONSTEXPR sprout::array<typename sprout::common_decay<Types...>::type, N>
|
|
|
|
make_array(Types&&... args) {
|
|
|
|
typedef typename sprout::common_decay<Types...>::type value_type;
|
|
|
|
typedef sprout::array<value_type, N> type;
|
|
|
|
return type{{value_type(SPROUT_FORWARD(Types, args))...}};
|
|
|
|
}
|
2014-04-15 04:37:38 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// make_array_without_narrowing
|
|
|
|
//
|
|
|
|
template<typename T, typename... Types>
|
|
|
|
inline SPROUT_CONSTEXPR sprout::array<typename std::remove_cv<T>::type, sizeof...(Types)>
|
|
|
|
make_array_without_narrowing(Types&&... args) {
|
|
|
|
return sprout::array<typename std::remove_cv<T>::type, sizeof...(Types)>{{SPROUT_FORWARD(Types, args)...}};
|
|
|
|
}
|
2016-04-03 12:00:55 +00:00
|
|
|
template<typename T, std::size_t N, typename... Types>
|
|
|
|
inline SPROUT_CONSTEXPR sprout::array<typename std::remove_cv<T>::type, N>
|
|
|
|
make_array_without_narrowing(Types&&... args) {
|
|
|
|
return sprout::array<typename std::remove_cv<T>::type, N>{{SPROUT_FORWARD(Types, args)...}};
|
|
|
|
}
|
2014-04-15 04:37:38 +00:00
|
|
|
template<sprout::detail::make_array_t = sprout::detail::make_array_in_common_elements, typename... Types>
|
|
|
|
inline SPROUT_CONSTEXPR sprout::array<typename sprout::common_decay<Types...>::type, sizeof...(Types)>
|
|
|
|
make_array_without_narrowing(Types&&... args) {
|
|
|
|
typedef typename sprout::common_decay<Types...>::type value_type;
|
|
|
|
typedef sprout::array<value_type, sizeof...(Types)> type;
|
|
|
|
return type{{SPROUT_FORWARD(Types, args)...}};
|
2014-04-15 03:31:13 +00:00
|
|
|
}
|
2016-04-03 12:00:55 +00:00
|
|
|
template<std::size_t N, sprout::detail::make_array_t = sprout::detail::make_array_in_common_elements, typename... Types>
|
|
|
|
inline SPROUT_CONSTEXPR sprout::array<typename sprout::common_decay<Types...>::type, N>
|
|
|
|
make_array_without_narrowing(Types&&... args) {
|
|
|
|
typedef typename sprout::common_decay<Types...>::type value_type;
|
|
|
|
typedef sprout::array<value_type, N> type;
|
|
|
|
return type{{SPROUT_FORWARD(Types, args)...}};
|
|
|
|
}
|
2012-06-22 10:14:21 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// make_common_array
|
|
|
|
//
|
|
|
|
template<typename... Types>
|
2013-10-25 15:32:36 +00:00
|
|
|
inline SPROUT_CONSTEXPR sprout::array<typename sprout::common_decay<Types...>::type, sizeof...(Types)>
|
2012-10-04 16:53:39 +00:00
|
|
|
make_common_array(Types&&... args) {
|
2014-04-15 03:31:13 +00:00
|
|
|
return sprout::make_array(SPROUT_FORWARD(Types, args)...);
|
2012-06-22 10:14:21 +00:00
|
|
|
}
|
2016-04-03 12:00:55 +00:00
|
|
|
template<std::size_t N, typename... Types>
|
|
|
|
inline SPROUT_CONSTEXPR sprout::array<typename sprout::common_decay<Types...>::type, N>
|
|
|
|
make_common_array(Types&&... args) {
|
|
|
|
return sprout::make_array<N>(SPROUT_FORWARD(Types, args)...);
|
|
|
|
}
|
2013-08-03 11:03:13 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// convert_array
|
2014-02-20 15:25:55 +00:00
|
|
|
// [[deprecated]]
|
2013-08-03 11:03:13 +00:00
|
|
|
//
|
|
|
|
template<typename T, typename Converter, typename... Types>
|
2014-02-20 15:25:55 +00:00
|
|
|
SPROUT_DEPRECATED
|
2013-08-03 11:03:13 +00:00
|
|
|
inline SPROUT_CONSTEXPR sprout::array<T, sizeof...(Types)>
|
|
|
|
convert_array(Converter&& conv, Types&&... args) {
|
2014-02-22 07:32:51 +00:00
|
|
|
return sprout::make_array<T>(SPROUT_FORWARD(Converter, conv)(SPROUT_FORWARD(Types, args))...);
|
2013-08-03 11:03:13 +00:00
|
|
|
}
|
2012-06-22 10:14:21 +00:00
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_ARRAY_MAKE_ARRAY_HPP
|