mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2024-11-12 21:09:01 +00:00
74 lines
3.2 KiB
C++
74 lines
3.2 KiB
C++
|
/*=============================================================================
|
||
|
Copyright (c) 2011-2016 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_VALARRAY_MAKE_VALARRAY_HPP
|
||
|
#define SPROUT_VALARRAY_MAKE_VALARRAY_HPP
|
||
|
|
||
|
#include <type_traits>
|
||
|
#include <sprout/config.hpp>
|
||
|
#include <sprout/workaround/std/cstddef.hpp>
|
||
|
#include <sprout/index_tuple/metafunction.hpp>
|
||
|
#include <sprout/valarray/valarray.hpp>
|
||
|
#include <sprout/utility/forward.hpp>
|
||
|
#include <sprout/type_traits/common_decay.hpp>
|
||
|
|
||
|
namespace sprout {
|
||
|
namespace detail {
|
||
|
enum make_valarray_t {
|
||
|
make_valarray_in_common_elements
|
||
|
};
|
||
|
} // namespace detail
|
||
|
//
|
||
|
// make_valarray
|
||
|
//
|
||
|
template<typename T, typename... Types>
|
||
|
inline SPROUT_CONSTEXPR sprout::valarray<typename std::remove_cv<T>::type, sizeof...(Types)>
|
||
|
make_valarray(Types&&... args) {
|
||
|
typedef sprout::valarray<typename std::remove_cv<T>::type, sizeof...(Types)> type;
|
||
|
typedef sprout::detail::make_construct_impl<type> construct_type;
|
||
|
return construct_type::make(T(SPROUT_FORWARD(Types, args))...);
|
||
|
}
|
||
|
template<sprout::detail::make_valarray_t = sprout::detail::make_valarray_in_common_elements, typename... Types>
|
||
|
inline SPROUT_CONSTEXPR sprout::valarray<typename sprout::common_decay<Types...>::type, sizeof...(Types)>
|
||
|
make_valarray(Types&&... args) {
|
||
|
typedef typename sprout::common_decay<Types...>::type value_type;
|
||
|
typedef sprout::valarray<value_type, sizeof...(Types)> type;
|
||
|
typedef sprout::detail::make_construct_impl<type> construct_type;
|
||
|
return construct_type::make(value_type(SPROUT_FORWARD(Types, args))...);
|
||
|
}
|
||
|
|
||
|
//
|
||
|
// make_valarray_without_narrowing
|
||
|
//
|
||
|
template<typename T, typename... Types>
|
||
|
inline SPROUT_CONSTEXPR sprout::valarray<typename std::remove_cv<T>::type, sizeof...(Types)>
|
||
|
make_valarray_without_narrowing(Types&&... args) {
|
||
|
typedef sprout::valarray<typename std::remove_cv<T>::type, sizeof...(Types)> type;
|
||
|
typedef sprout::detail::make_construct_impl<type> construct_type;
|
||
|
return construct_type::make(SPROUT_FORWARD(Types, args)...);
|
||
|
}
|
||
|
template<sprout::detail::make_valarray_t = sprout::detail::make_valarray_in_common_elements, typename... Types>
|
||
|
inline SPROUT_CONSTEXPR sprout::valarray<typename sprout::common_decay<Types...>::type, sizeof...(Types)>
|
||
|
make_valarray_without_narrowing(Types&&... args) {
|
||
|
typedef typename sprout::common_decay<Types...>::type value_type;
|
||
|
typedef sprout::valarray<value_type, sizeof...(Types)> type;
|
||
|
typedef sprout::detail::make_construct_impl<type> construct_type;
|
||
|
return construct_type::make(SPROUT_FORWARD(Types, args)...);
|
||
|
}
|
||
|
|
||
|
//
|
||
|
// make_common_valarray
|
||
|
//
|
||
|
template<typename... Types>
|
||
|
inline SPROUT_CONSTEXPR sprout::valarray<typename sprout::common_decay<Types...>::type, sizeof...(Types)>
|
||
|
make_common_valarray(Types&&... args) {
|
||
|
return sprout::make_valarray(SPROUT_FORWARD(Types, args)...);
|
||
|
}
|
||
|
} // namespace sprout
|
||
|
|
||
|
#endif // #ifndef SPROUT_VALARRAY_MAKE_VALARRAY_HPP
|