chande udl namespace

This commit is contained in:
bolero-MURAKAMI 2016-04-16 09:50:04 +09:00
parent a6d46d4ffa
commit 69c9233ca0
10 changed files with 234 additions and 152 deletions

View file

@ -0,0 +1,21 @@
/*=============================================================================
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_DETAIL_DO_NOTHING_STATEMENT_WITHIN_NAMESPACE_HPP
#define SPROUT_DETAIL_DO_NOTHING_STATEMENT_WITHIN_NAMESPACE_HPP
#include <sprout/config.hpp>
namespace sprout_detail_do_nothing_statement {}
//
// SPROUT_DETAIL_DO_NOTHING_STATEMENT_WITHIN_NAMESPACE
//
#define SPROUT_DETAIL_DO_NOTHING_STATEMENT_WITHIN_NAMESPACE \
using namespace sprout_detail_do_nothing_statement
#endif // #ifndef SPROUT_DETAIL_DO_NOTHING_STATEMENT_WITHIN_NAMESPACE_HPP

View file

@ -34,8 +34,8 @@ namespace sprout {
>
{};
namespace placeholders {
namespace udl {
namespace udl {
namespace placeholders {
//
// _
// _tail
@ -52,17 +52,10 @@ namespace sprout {
typedef typename sprout::variadic_placeholders_result<Chars...>::type type;
return type();
}
} // namespace udl
} // namespace placeholders
namespace udl {
namespace placeholders {
using sprout::placeholders::udl::operator"" _;
using sprout::placeholders::udl::operator"" _tail;
} // namespace placeholders
using sprout::placeholders::udl::operator"" _;
using sprout::placeholders::udl::operator"" _tail;
using sprout::udl::placeholders::operator"" _;
using sprout::udl::placeholders::operator"" _tail;
} // namespace udl
} // namespace sprout

View file

@ -9,7 +9,9 @@
#define SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_HPP
#include <sprout/config.hpp>
#include <sprout/type_traits/is_within_tag_namespace.hpp>
#include <sprout/type_traits/is_within_namespace_sprout.hpp>
#include <sprout/type_traits/is_within_namespace_std.hpp>
#include <sprout/type_traits/is_within_namespace_boost.hpp>
#endif // #ifndef SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_HPP

View file

@ -8,53 +8,18 @@
#ifndef SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_BOOST_HPP
#define SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_BOOST_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/type_traits/integral_constant.hpp>
#include <sprout/type_traits/identity.hpp>
#include <sprout/adl/not_found.hpp>
namespace sprout_adl {
sprout::not_found_via_adl sprout_adl_tester_namespace_boost(...);
} // namespace sprout_adl
#include <sprout/type_traits/is_within_tag_namespace.hpp>
namespace boost {
template<typename T>
void sprout_adl_tester_namespace_boost(T&&);
SPROUT_ADL_TESTER_DECL(boost);
} // namespace boost
namespace sprout_adl_tester_detail {
using sprout_adl::sprout_adl_tester_namespace_boost;
template<typename T>
struct is_within_namespace_boost_test {
public:
template<
typename U = T,
typename R = typename sprout::identity<decltype(sprout_adl_tester_namespace_boost(std::declval<U>()))>::type
>
static sprout::is_found_via_adl<R> test(int);
static sprout::false_type test(...);
};
} // namespace sprout_adl_tester_detail
namespace sprout {
#if defined(_MSC_VER) && (_MSC_VER > 1900)
template<typename T, typename Base_ = typename sprout::identity<decltype(sprout_adl_tester_detail::is_within_namespace_boost_test<T>::test(0))>::type>
struct is_within_namespace_boost
: public Base_
{};
#else
template<typename T>
struct is_within_namespace_boost
: public sprout::identity<decltype(sprout_adl_tester_detail::is_within_namespace_boost_test<T>::test(0))>::type
{};
#endif
#if SPROUT_USE_VARIABLE_TEMPLATES
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_within_namespace_boost_v = sprout::is_within_namespace_boost<T>::value;
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
//
// is_within_namespace_boost
//
SPROUT_IS_WITHIN_NAMESPACE_DECL(boost, boost);
} // namespace sprout
#endif // #ifndef SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_BOOST_HPP

View file

@ -8,53 +8,18 @@
#ifndef SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_SPROUT_HPP
#define SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_SPROUT_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/type_traits/integral_constant.hpp>
#include <sprout/type_traits/identity.hpp>
#include <sprout/adl/not_found.hpp>
namespace sprout_adl {
sprout::not_found_via_adl sprout_adl_tester_namespace_sprout(...);
} // namespace sprout_adl
#include <sprout/type_traits/is_within_tag_namespace.hpp>
namespace sprout {
template<typename T>
void sprout_adl_tester_namespace_sprout(T&&);
SPROUT_ADL_TESTER_DECL(sprout);
} // namespace sprout
namespace sprout_adl_tester_detail {
using sprout_adl::sprout_adl_tester_namespace_sprout;
template<typename T>
struct is_within_namespace_sprout_test {
public:
template<
typename U = T,
typename R = typename sprout::identity<decltype(sprout_adl_tester_namespace_sprout(std::declval<U>()))>::type
>
static sprout::is_found_via_adl<R> test(int);
static sprout::false_type test(...);
};
} // namespace sprout_adl_tester_detail
namespace sprout {
#if defined(_MSC_VER) && (_MSC_VER > 1900)
template<typename T, typename Base_ = typename sprout::identity<decltype(sprout_adl_tester_detail::is_within_namespace_sprout_test<T>::test(0))>::type>
struct is_within_namespace_sprout
: public Base_
{};
#else
template<typename T>
struct is_within_namespace_sprout
: public sprout::identity<decltype(sprout_adl_tester_detail::is_within_namespace_sprout_test<T>::test(0))>::type
{};
#endif
#if SPROUT_USE_VARIABLE_TEMPLATES
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_within_namespace_sprout_v = sprout::is_within_namespace_sprout<T>::value;
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
//
// is_within_namespace_sprout
//
SPROUT_IS_WITHIN_NAMESPACE_DECL(sprout, sprout);
} // namespace sprout
#endif // #ifndef SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_SPROUT_HPP

View file

@ -0,0 +1,32 @@
/*=============================================================================
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.std.org/LICENSE_1_0.txt)
=============================================================================*/
#ifndef SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_STD_HPP
#define SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_STD_HPP
#include <sprout/config.hpp>
#include <sprout/type_traits/is_within_tag_namespace.hpp>
//
// note:
// This code is ill-formed in the Standard C++
// because adding declarations to std namespace.
// However, it will work without problems in practice.
// I want to replace if there is a better way.
//
namespace std {
SPROUT_ADL_TESTER_DECL(std);
} // namespace std
namespace sprout {
//
// is_within_namespace_std
//
SPROUT_IS_WITHIN_NAMESPACE_DECL(std, std);
} // namespace sprout
#endif // #ifndef SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_STD_HPP

View file

@ -0,0 +1,106 @@
/*=============================================================================
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_TYPE_TRAITS_IS_WITHIN_TAG_NAMESPACE_HPP
#define SPROUT_TYPE_TRAITS_IS_WITHIN_TAG_NAMESPACE_HPP
#include <utility>
#include <sprout/config.hpp>
#include <sprout/type_traits/integral_constant.hpp>
#include <sprout/type_traits/identity.hpp>
#include <sprout/preprocessor/cat.hpp>
#include <sprout/preprocessor/empty.hpp>
#include <sprout/adl/not_found.hpp>
#include <sprout/detail/do_nothing_statement.hpp>
//
// SPROUT_ADL_TEST_TAG_DECL
//
#define SPROUT_ADL_TEST_TAG_DECL(NAME) \
namespace sprout_adl_test { \
struct SPROUT_PP_CAT(NAME, _tag); \
} SPROUT_DETAIL_DO_NOTHING_STATEMENT_WITHIN_NAMESPACE
//
// SPROUT_ADL_TESTER_DECL
//
#define SPROUT_ADL_TESTER_DECL(NAME) \
SPROUT_ADL_TEST_TAG_DECL(NAME); \
template<typename T> \
void sprout_adl_tester(sprout_adl_test::SPROUT_PP_CAT(NAME, _tag)&&, T&&)
//
// SPROUT_ADL_TEST_TAG
//
#define SPROUT_ADL_TEST_TAG(NAME) \
sprout_adl_test::SPROUT_PP_CAT(NAME, _tag)
//
// SPROUT_IS_WITHIN_NAMESPACE_DECL
//
#define SPROUT_IS_WITHIN_NAMESPACE_DECL(NAME, NAMESPACE) \
template<typename T> \
struct SPROUT_PP_CAT(is_within_namespace_, NAME) \
: public sprout::is_within_tag_namespace<NAMESPACE::SPROUT_ADL_TEST_TAG(NAME), T> \
{}; \
SPROUT_IS_WITHIN_NAMESPACE_V(NAME, NAMESPACE);
#if SPROUT_USE_VARIABLE_TEMPLATES
# define SPROUT_IS_WITHIN_NAMESPACE_V(NAME, NAMESPACE) \
template<typename T>
SPROUT_STATIC_CONSTEXPR bool SPROUT_PP_CAT(SPROUT_PP_CAT(is_within_namespace_, NAME), _v) = SPROUT_PP_CAT(is_within_namespace_, NAME)<T>::value
#else // #if SPROUT_USE_VARIABLE_TEMPLATES
# define SPROUT_IS_WITHIN_NAMESPACE_V(NAME, NAMESPACE) \
SPROUT_DETAIL_DO_NOTHING_STATEMENT_WITHIN_NAMESPACE
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
namespace sprout_adl {
sprout::not_found_via_adl sprout_adl_tester(...);
} // namespace sprout_adl
namespace sprout_adl_tester_detail {
using sprout_adl::sprout_adl_tester;
template<typename Tag, typename T>
struct is_within_namespace_test {
public:
template<
typename Tag0 = Tag, typename U = T,
typename R = typename sprout::identity<decltype(sprout_adl_tester(std::declval<Tag0>(), std::declval<U>()))>::type
>
static sprout::is_found_via_adl<R> test(int);
static sprout::false_type test(...);
};
} // namespace sprout_adl_tester_detail
namespace sprout {
//
// is_within_tag_namespace
//
#if defined(_MSC_VER) && (_MSC_VER > 1900)
namespace detail {
template<typename Tag, typename T, typename Base_ = typename sprout::identity<decltype(sprout_adl_tester_detail::is_within_namespace_test<Tag, T>::test(0))>::type>
struct is_within_tag_namespace_impl
: public Base_
{};
} // namespace detail
template<typename Tag, typename T>
struct is_within_tag_namespace
: public sprout::detail::is_within_tag_namespace_impl<Tag, T>
{};
#else
template<typename Tag, typename T>
struct is_within_tag_namespace
: public sprout::identity<decltype(sprout_adl_tester_detail::is_within_namespace_test<Tag, T>::test(0))>::type
{};
#endif
#if SPROUT_USE_VARIABLE_TEMPLATES
template<typename Tag, typename T>
SPROUT_STATIC_CONSTEXPR bool is_within_tag_namespace_v = sprout::is_within_tag_namespace<Tag, T>::value;
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
} // namespace sprout
#endif // #ifndef SPROUT_TYPE_TRAITS_IS_WITHIN_TAG_NAMESPACE_HPP

View file

@ -160,30 +160,34 @@ namespace sprout {
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
namespace udl {
//
// _sr
//
inline SPROUT_CONSTEXPR sprout::basic_string_view<char>
operator"" _sr(char const* s, std::size_t size) {
return sprout::basic_string_view<char>(s, size);
}
inline SPROUT_CONSTEXPR sprout::basic_string_view<wchar_t>
operator"" _sr(wchar_t const* s, std::size_t size) {
return sprout::basic_string_view<wchar_t>(s, size);
}
namespace strings {
//
// _sr
//
inline SPROUT_CONSTEXPR sprout::basic_string_view<char>
operator"" _sr(char const* s, std::size_t size) {
return sprout::basic_string_view<char>(s, size);
}
inline SPROUT_CONSTEXPR sprout::basic_string_view<wchar_t>
operator"" _sr(wchar_t const* s, std::size_t size) {
return sprout::basic_string_view<wchar_t>(s, size);
}
#if SPROUT_USE_UNICODE_LITERALS
inline SPROUT_CONSTEXPR sprout::basic_string_view<char16_t>
operator"" _sr(char16_t const* s, std::size_t size) {
return sprout::basic_string_view<char16_t>(s, size);
}
inline SPROUT_CONSTEXPR sprout::basic_string_view<char32_t>
operator"" _sr(char32_t const* s, std::size_t size) {
return sprout::basic_string_view<char32_t>(s, size);
}
inline SPROUT_CONSTEXPR sprout::basic_string_view<char16_t>
operator"" _sr(char16_t const* s, std::size_t size) {
return sprout::basic_string_view<char16_t>(s, size);
}
inline SPROUT_CONSTEXPR sprout::basic_string_view<char32_t>
operator"" _sr(char32_t const* s, std::size_t size) {
return sprout::basic_string_view<char32_t>(s, size);
}
#endif
} // namespace strings
using sprout::udl::strings::operator"" _sr;
} // namespace udl
using sprout::udl::operator"" _sr;
using sprout::udl::strings::operator"" _sr;
} // namespace sprout
#endif // #ifndef SPROUT_UTILITY_STRING_VIEW_STRING_REF_HPP

View file

@ -17,30 +17,34 @@
namespace sprout {
namespace udl {
//
// _sv
//
inline SPROUT_CONSTEXPR sprout::basic_string_view<char>
operator"" _sv(char const* s, std::size_t size) {
return sprout::basic_string_view<char>(s, size);
}
inline SPROUT_CONSTEXPR sprout::basic_string_view<wchar_t>
operator"" _sv(wchar_t const* s, std::size_t size) {
return sprout::basic_string_view<wchar_t>(s, size);
}
namespace strings {
//
// _sv
//
inline SPROUT_CONSTEXPR sprout::basic_string_view<char>
operator"" _sv(char const* s, std::size_t size) {
return sprout::basic_string_view<char>(s, size);
}
inline SPROUT_CONSTEXPR sprout::basic_string_view<wchar_t>
operator"" _sv(wchar_t const* s, std::size_t size) {
return sprout::basic_string_view<wchar_t>(s, size);
}
#if SPROUT_USE_UNICODE_LITERALS
inline SPROUT_CONSTEXPR sprout::basic_string_view<char16_t>
operator"" _sv(char16_t const* s, std::size_t size) {
return sprout::basic_string_view<char16_t>(s, size);
}
inline SPROUT_CONSTEXPR sprout::basic_string_view<char32_t>
operator"" _sv(char32_t const* s, std::size_t size) {
return sprout::basic_string_view<char32_t>(s, size);
}
inline SPROUT_CONSTEXPR sprout::basic_string_view<char16_t>
operator"" _sv(char16_t const* s, std::size_t size) {
return sprout::basic_string_view<char16_t>(s, size);
}
inline SPROUT_CONSTEXPR sprout::basic_string_view<char32_t>
operator"" _sv(char32_t const* s, std::size_t size) {
return sprout::basic_string_view<char32_t>(s, size);
}
#endif
} // namespace strings
using sprout::udl::strings::operator"" _sv;
} // namespace udl
using sprout::udl::operator"" _sv;
using sprout::udl::strings::operator"" _sv;
} // namespace sprout
#endif // #if SPROUT_USE_USER_DEFINED_LITERALS

View file

@ -59,8 +59,10 @@ namespace sprout {
;
}
} // namespace detail
} // namespace uuids
namespace udl {
namespace udl {
namespace uuids {
//
// _uuid
//
@ -126,28 +128,16 @@ namespace sprout {
return sprout::uuids::detail::uuid5_impl(sprout::range::make_ptr_range(s, size));
}
#endif
} // namespace udl
using sprout::uuids::udl::operator"" _uuid;
using sprout::uuids::udl::operator"" _uuid3;
using sprout::uuids::udl::operator"" _uuid5;
} // namespace uuids
namespace udl {
namespace uuids {
using sprout::uuids::udl::operator"" _uuid;
using sprout::uuids::udl::operator"" _uuid3;
using sprout::uuids::udl::operator"" _uuid5;
} // namespace uuids
using sprout::uuids::udl::operator"" _uuid;
using sprout::uuids::udl::operator"" _uuid3;
using sprout::uuids::udl::operator"" _uuid5;
using sprout::udl::uuids::operator"" _uuid;
using sprout::udl::uuids::operator"" _uuid3;
using sprout::udl::uuids::operator"" _uuid5;
} // namespace udl
using sprout::uuids::udl::operator"" _uuid;
using sprout::uuids::udl::operator"" _uuid3;
using sprout::uuids::udl::operator"" _uuid5;
using sprout::udl::uuids::operator"" _uuid;
using sprout::udl::uuids::operator"" _uuid3;
using sprout::udl::uuids::operator"" _uuid5;
} // namespace sprout
#endif // #if SPROUT_USE_USER_DEFINED_LITERALS