1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-11-12 21:09:01 +00:00
Sprout/sprout/array/make_array.hpp

53 lines
1.8 KiB
C++
Raw Normal View History

2013-08-08 09:54:33 +00:00
/*=============================================================================
Copyright (c) 2011-2013 Bolero MURAKAMI
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)
=============================================================================*/
#ifndef SPROUT_ARRAY_MAKE_ARRAY_HPP
#define SPROUT_ARRAY_MAKE_ARRAY_HPP
#include <cstddef>
#include <type_traits>
#include <sprout/config.hpp>
2013-04-06 04:06:51 +00:00
#include <sprout/index_tuple/metafunction.hpp>
#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>
namespace sprout {
//
// make_array
//
template<typename T, typename... Types>
inline SPROUT_CONSTEXPR sprout::array<T, sizeof...(Types)>
make_array(Types&&... args) {
return sprout::array<T, sizeof...(Types)>{{T(sprout::forward<Types>(args))...}};
}
//
// make_common_array
//
template<typename... Types>
2013-08-29 14:21:49 +00:00
inline SPROUT_CONSTEXPR sprout::array<typename sprout::common_decay<Types&&...>::type, sizeof...(Types)>
make_common_array(Types&&... args) {
typedef sprout::array<
2013-03-23 14:46:03 +00:00
typename sprout::common_decay<Types&&...>::type,
sizeof...(Types)
> type;
return type{{typename sprout::common_decay<Types&&...>::type(sprout::forward<Types>(args))...}};
}
2013-08-03 11:03:13 +00:00
//
// convert_array
//
template<typename T, typename Converter, typename... Types>
inline SPROUT_CONSTEXPR sprout::array<T, sizeof...(Types)>
convert_array(Converter&& conv, Types&&... args) {
return sprout::make_array<T>(sprout::forward<Converter>(conv)(sprout::forward<Types>(args))...);
}
} // namespace sprout
#endif // #ifndef SPROUT_ARRAY_MAKE_ARRAY_HPP