mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
add bool_constant [N4334]
This commit is contained in:
parent
fbb95d9068
commit
a1f6d6ffc3
35 changed files with 198 additions and 106 deletions
|
@ -11,6 +11,7 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/string/char_traits.hpp>
|
||||
#include <sprout/utility/string_ref/string_ref.hpp>
|
||||
#include <sprout/utility/string_ref/type_traits.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
|
@ -41,6 +42,125 @@ namespace sprout {
|
|||
template<typename T, typename Traits = sprout::char_traits<T> >
|
||||
using basic_string_view = sprout::basic_string_ref<T, Traits>;
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
|
||||
//
|
||||
// to_string_view
|
||||
//
|
||||
template<typename T, typename Traits>
|
||||
inline SPROUT_CONSTEXPR sprout::basic_string_ref<T, Traits>
|
||||
to_string_view(sprout::basic_string_ref<T, Traits> const& s) {
|
||||
return sprout::to_string_ref(s);
|
||||
}
|
||||
template<typename T, std::size_t N, typename Traits>
|
||||
inline SPROUT_CONSTEXPR sprout::basic_string_ref<T, Traits>
|
||||
to_string_view(sprout::basic_string<T, N, Traits> const& s) {
|
||||
return sprout::to_string_ref(s);
|
||||
}
|
||||
template<typename T, typename Traits>
|
||||
inline SPROUT_NON_CONSTEXPR sprout::basic_string_ref<T, Traits>
|
||||
to_string_view(std::basic_string<T, Traits> const& s) {
|
||||
return sprout::to_string_ref(s);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR sprout::basic_string_ref<T>
|
||||
to_string_view(T const* str) {
|
||||
return sprout::to_string_ref(str);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR sprout::basic_string_ref<T>
|
||||
to_string_view(T const* str, std::size_t len) {
|
||||
return sprout::to_string_ref(str, len);
|
||||
}
|
||||
|
||||
//
|
||||
// is_basic_string_view
|
||||
//
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T>
|
||||
using is_basic_string_view = sprout::is_basic_string_ref<T>;
|
||||
#else // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T>
|
||||
struct is_basic_string_view
|
||||
: public sprout::is_basic_string_ref<T>
|
||||
{};
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
|
||||
//
|
||||
// is_string_view_of
|
||||
//
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T, typename Elem>
|
||||
using is_string_view_of = sprout::is_string_ref_of<T, Elem>;
|
||||
#else // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T, typename Elem>
|
||||
struct is_string_view_of
|
||||
: public sprout::is_string_ref_of<T, Elem>
|
||||
{};
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
|
||||
//
|
||||
// is_string_view
|
||||
//
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T>
|
||||
using is_string_view = sprout::is_string_ref<T>;
|
||||
#else // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T, typename Elem>
|
||||
struct is_string_view
|
||||
: public sprout::is_string_ref<T>
|
||||
{};
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
//
|
||||
// is_wstring_view
|
||||
//
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T>
|
||||
using is_wstring_view = sprout::is_wstring_ref<T>;
|
||||
#else // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T, typename Elem>
|
||||
struct is_wstring_view
|
||||
: public sprout::is_wstring_ref<T>
|
||||
{};
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
//
|
||||
// is_u16string_view
|
||||
//
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T>
|
||||
using is_u16string_view = sprout::is_u16string_ref<T>;
|
||||
#else // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T, typename Elem>
|
||||
struct is_u16string_view
|
||||
: public sprout::is_u16string_ref<T>
|
||||
{};
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
//
|
||||
// is_u32string_view
|
||||
//
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T>
|
||||
using is_u32string_view = sprout::is_u32string_ref<T>;
|
||||
#else // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T, typename Elem>
|
||||
struct is_u32string_view
|
||||
: public sprout::is_u32string_ref<T>
|
||||
{};
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
|
||||
#if SPROUT_USE_VARIABLE_TEMPLATES
|
||||
template<typename T>
|
||||
SPROUT_STATIC_CONSTEXPR bool is_basic_string_view_v = sprout::is_basic_string_view<T>::value;
|
||||
template<typename T, typename Elem>
|
||||
SPROUT_STATIC_CONSTEXPR bool is_string_view_of_v = sprout::is_string_view_of<T, Elem>::value;
|
||||
template<typename T>
|
||||
SPROUT_STATIC_CONSTEXPR bool is_string_view_v = sprout::is_string_view<T>::value;
|
||||
template<typename T>
|
||||
SPROUT_STATIC_CONSTEXPR bool is_wstring_view_v = sprout::is_wstring_view<T>::value;
|
||||
template<typename T>
|
||||
SPROUT_STATIC_CONSTEXPR bool is_u16string_view_v = sprout::is_u16string_view<T>::value;
|
||||
template<typename T>
|
||||
SPROUT_STATIC_CONSTEXPR bool is_u32string_view_v = sprout::is_u32string_view<T>::value;
|
||||
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_UTILITY_STRING_REF_ALIAS_HPP
|
||||
|
|
|
@ -54,8 +54,7 @@ namespace sprout {
|
|||
private:
|
||||
template<typename Iterator>
|
||||
class is_string_ref_iterator
|
||||
: public sprout::integral_constant<
|
||||
bool,
|
||||
: public sprout::bool_constant<
|
||||
std::is_same<Iterator, sprout::index_iterator<basic_string_ref&, true> >::value
|
||||
|| std::is_same<Iterator, sprout::index_iterator<basic_string_ref const&, true> >::value
|
||||
>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue