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

72 lines
3.1 KiB
C++
Raw Permalink Normal View History

2013-08-08 09:54:33 +00:00
/*=============================================================================
Copyright (c) 2011-2019 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-04-14 10:06:21 +00:00
#ifndef SPROUT_STRING_MAKE_STRING_HPP
#define SPROUT_STRING_MAKE_STRING_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/workaround/std/cstddef.hpp>
2012-04-14 10:06:21 +00:00
#include <sprout/string/char_traits.hpp>
#include <sprout/string/string.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
namespace detail {
enum make_string_t {
make_string_in_head_type
};
} // namespace detail
2012-04-14 10:06:21 +00:00
//
// make_string
//
template<typename T>
inline SPROUT_CONSTEXPR sprout::basic_string<typename std::decay<T>::type, 0>
make_string() {
return sprout::basic_string<typename std::decay<T>::type, 0>();
2012-04-14 10:06:21 +00:00
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::basic_string<typename std::decay<T>::type, N>
make_string() {
return sprout::basic_string<typename std::decay<T>::type, N>();
}
template<typename T, typename Head, typename... Tail>
inline SPROUT_CONSTEXPR sprout::basic_string<typename std::decay<T>::type, 1 + sizeof...(Tail)>
make_string(Head&& head, Tail&&... tail) {
typedef sprout::detail::make_construct_impl<
sprout::basic_string<typename std::decay<T>::type, 1 + sizeof...(Tail)>
> impl_type;
return impl_type::make(SPROUT_FORWARD(Head, head), SPROUT_FORWARD(Tail, tail)...);
}
template<typename T, std::size_t N, typename Head, typename... Tail>
inline SPROUT_CONSTEXPR sprout::basic_string<typename std::decay<T>::type, N>
make_string(Head&& head, Tail&&... tail) {
typedef sprout::detail::make_construct_impl<
sprout::basic_string<typename std::decay<T>::type, N>
> impl_type;
return impl_type::make(SPROUT_FORWARD(Head, head), SPROUT_FORWARD(Tail, tail)...);
}
template<sprout::detail::make_string_t = sprout::detail::make_string_in_head_type, typename Head, typename... Tail>
inline SPROUT_CONSTEXPR sprout::basic_string<typename std::decay<Head>::type, 1 + sizeof...(Tail)>
make_string(Head&& head, Tail&&... tail) {
typedef sprout::detail::make_construct_impl<
sprout::basic_string<typename std::decay<Head>::type, 1 + sizeof...(Tail)>
> impl_type;
return impl_type::make(SPROUT_FORWARD(Head, head), SPROUT_FORWARD(Tail, tail)...);
}
template<std::size_t N, sprout::detail::make_string_t = sprout::detail::make_string_in_head_type, typename Head, typename... Tail>
inline SPROUT_CONSTEXPR sprout::basic_string<typename std::decay<Head>::type, N>
make_string(Head&& head, Tail&&... tail) {
typedef sprout::detail::make_construct_impl<
sprout::basic_string<typename std::decay<Head>::type, N>
> impl_type;
return impl_type::make(SPROUT_FORWARD(Head, head), SPROUT_FORWARD(Tail, tail)...);
2012-04-14 10:06:21 +00:00
}
} // namespace sprout
#endif // #ifndef SPROUT_STRING_MAKE_STRING_HPP