diff --git a/sprout/detail/do_nothing_statement.hpp b/sprout/detail/do_nothing_statement.hpp new file mode 100644 index 00000000..74d92c45 --- /dev/null +++ b/sprout/detail/do_nothing_statement.hpp @@ -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 + +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 diff --git a/sprout/functional/bind/udl.hpp b/sprout/functional/bind/udl.hpp index b1ba47b3..99e3cebc 100644 --- a/sprout/functional/bind/udl.hpp +++ b/sprout/functional/bind/udl.hpp @@ -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::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 diff --git a/sprout/type_traits/is_within_namespace.hpp b/sprout/type_traits/is_within_namespace.hpp index a20de099..3711ff28 100644 --- a/sprout/type_traits/is_within_namespace.hpp +++ b/sprout/type_traits/is_within_namespace.hpp @@ -9,7 +9,9 @@ #define SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_HPP #include +#include #include +#include #include #endif // #ifndef SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_HPP diff --git a/sprout/type_traits/is_within_namespace_boost.hpp b/sprout/type_traits/is_within_namespace_boost.hpp index f7a6d27c..0556acde 100644 --- a/sprout/type_traits/is_within_namespace_boost.hpp +++ b/sprout/type_traits/is_within_namespace_boost.hpp @@ -8,53 +8,18 @@ #ifndef SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_BOOST_HPP #define SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_BOOST_HPP -#include #include -#include -#include -#include - -namespace sprout_adl { - sprout::not_found_via_adl sprout_adl_tester_namespace_boost(...); -} // namespace sprout_adl +#include namespace boost { - template - 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 - struct is_within_namespace_boost_test { - public: - template< - typename U = T, - typename R = typename sprout::identity()))>::type - > - static sprout::is_found_via_adl test(int); - static sprout::false_type test(...); - }; -} // namespace sprout_adl_tester_detail - namespace sprout { -#if defined(_MSC_VER) && (_MSC_VER > 1900) - template::test(0))>::type> - struct is_within_namespace_boost - : public Base_ - {}; -#else - template - struct is_within_namespace_boost - : public sprout::identity::test(0))>::type - {}; -#endif - -#if SPROUT_USE_VARIABLE_TEMPLATES - template - SPROUT_STATIC_CONSTEXPR bool is_within_namespace_boost_v = sprout::is_within_namespace_boost::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 diff --git a/sprout/type_traits/is_within_namespace_sprout.hpp b/sprout/type_traits/is_within_namespace_sprout.hpp index 3538c229..1e665ef8 100644 --- a/sprout/type_traits/is_within_namespace_sprout.hpp +++ b/sprout/type_traits/is_within_namespace_sprout.hpp @@ -8,53 +8,18 @@ #ifndef SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_SPROUT_HPP #define SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_SPROUT_HPP -#include #include -#include -#include -#include - -namespace sprout_adl { - sprout::not_found_via_adl sprout_adl_tester_namespace_sprout(...); -} // namespace sprout_adl +#include namespace sprout { - template - 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 - struct is_within_namespace_sprout_test { - public: - template< - typename U = T, - typename R = typename sprout::identity()))>::type - > - static sprout::is_found_via_adl test(int); - static sprout::false_type test(...); - }; -} // namespace sprout_adl_tester_detail - namespace sprout { -#if defined(_MSC_VER) && (_MSC_VER > 1900) - template::test(0))>::type> - struct is_within_namespace_sprout - : public Base_ - {}; -#else - template - struct is_within_namespace_sprout - : public sprout::identity::test(0))>::type - {}; -#endif - -#if SPROUT_USE_VARIABLE_TEMPLATES - template - SPROUT_STATIC_CONSTEXPR bool is_within_namespace_sprout_v = sprout::is_within_namespace_sprout::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 diff --git a/sprout/type_traits/is_within_namespace_std.hpp b/sprout/type_traits/is_within_namespace_std.hpp new file mode 100644 index 00000000..929cf157 --- /dev/null +++ b/sprout/type_traits/is_within_namespace_std.hpp @@ -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 +#include + +// +// 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 diff --git a/sprout/type_traits/is_within_tag_namespace.hpp b/sprout/type_traits/is_within_tag_namespace.hpp new file mode 100644 index 00000000..cf9dcfba --- /dev/null +++ b/sprout/type_traits/is_within_tag_namespace.hpp @@ -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 +#include +#include +#include +#include +#include +#include +#include + +// +// 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 \ + 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 \ + struct SPROUT_PP_CAT(is_within_namespace_, NAME) \ + : public sprout::is_within_tag_namespace \ + {}; \ + SPROUT_IS_WITHIN_NAMESPACE_V(NAME, NAMESPACE); +#if SPROUT_USE_VARIABLE_TEMPLATES +# define SPROUT_IS_WITHIN_NAMESPACE_V(NAME, NAMESPACE) \ + template + SPROUT_STATIC_CONSTEXPR bool SPROUT_PP_CAT(SPROUT_PP_CAT(is_within_namespace_, NAME), _v) = SPROUT_PP_CAT(is_within_namespace_, NAME)::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 + struct is_within_namespace_test { + public: + template< + typename Tag0 = Tag, typename U = T, + typename R = typename sprout::identity(), std::declval()))>::type + > + static sprout::is_found_via_adl 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::test(0))>::type> + struct is_within_tag_namespace_impl + : public Base_ + {}; + } // namespace detail + template + struct is_within_tag_namespace + : public sprout::detail::is_within_tag_namespace_impl + {}; +#else + template + struct is_within_tag_namespace + : public sprout::identity::test(0))>::type + {}; +#endif + +#if SPROUT_USE_VARIABLE_TEMPLATES + template + SPROUT_STATIC_CONSTEXPR bool is_within_tag_namespace_v = sprout::is_within_tag_namespace::value; +#endif // #if SPROUT_USE_VARIABLE_TEMPLATES +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_IS_WITHIN_TAG_NAMESPACE_HPP diff --git a/sprout/utility/string_view/string_ref.hpp b/sprout/utility/string_view/string_ref.hpp index f6d7c96f..921a5f2f 100644 --- a/sprout/utility/string_view/string_ref.hpp +++ b/sprout/utility/string_view/string_ref.hpp @@ -160,30 +160,34 @@ namespace sprout { #endif // #if SPROUT_USE_VARIABLE_TEMPLATES namespace udl { - // - // _sr - // - inline SPROUT_CONSTEXPR sprout::basic_string_view - operator"" _sr(char const* s, std::size_t size) { - return sprout::basic_string_view(s, size); - } - inline SPROUT_CONSTEXPR sprout::basic_string_view - operator"" _sr(wchar_t const* s, std::size_t size) { - return sprout::basic_string_view(s, size); - } + namespace strings { + // + // _sr + // + inline SPROUT_CONSTEXPR sprout::basic_string_view + operator"" _sr(char const* s, std::size_t size) { + return sprout::basic_string_view(s, size); + } + inline SPROUT_CONSTEXPR sprout::basic_string_view + operator"" _sr(wchar_t const* s, std::size_t size) { + return sprout::basic_string_view(s, size); + } #if SPROUT_USE_UNICODE_LITERALS - inline SPROUT_CONSTEXPR sprout::basic_string_view - operator"" _sr(char16_t const* s, std::size_t size) { - return sprout::basic_string_view(s, size); - } - inline SPROUT_CONSTEXPR sprout::basic_string_view - operator"" _sr(char32_t const* s, std::size_t size) { - return sprout::basic_string_view(s, size); - } + inline SPROUT_CONSTEXPR sprout::basic_string_view + operator"" _sr(char16_t const* s, std::size_t size) { + return sprout::basic_string_view(s, size); + } + inline SPROUT_CONSTEXPR sprout::basic_string_view + operator"" _sr(char32_t const* s, std::size_t size) { + return sprout::basic_string_view(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 diff --git a/sprout/utility/string_view/udl.hpp b/sprout/utility/string_view/udl.hpp index 900c8a9b..e6358221 100644 --- a/sprout/utility/string_view/udl.hpp +++ b/sprout/utility/string_view/udl.hpp @@ -17,30 +17,34 @@ namespace sprout { namespace udl { - // - // _sv - // - inline SPROUT_CONSTEXPR sprout::basic_string_view - operator"" _sv(char const* s, std::size_t size) { - return sprout::basic_string_view(s, size); - } - inline SPROUT_CONSTEXPR sprout::basic_string_view - operator"" _sv(wchar_t const* s, std::size_t size) { - return sprout::basic_string_view(s, size); - } + namespace strings { + // + // _sv + // + inline SPROUT_CONSTEXPR sprout::basic_string_view + operator"" _sv(char const* s, std::size_t size) { + return sprout::basic_string_view(s, size); + } + inline SPROUT_CONSTEXPR sprout::basic_string_view + operator"" _sv(wchar_t const* s, std::size_t size) { + return sprout::basic_string_view(s, size); + } #if SPROUT_USE_UNICODE_LITERALS - inline SPROUT_CONSTEXPR sprout::basic_string_view - operator"" _sv(char16_t const* s, std::size_t size) { - return sprout::basic_string_view(s, size); - } - inline SPROUT_CONSTEXPR sprout::basic_string_view - operator"" _sv(char32_t const* s, std::size_t size) { - return sprout::basic_string_view(s, size); - } + inline SPROUT_CONSTEXPR sprout::basic_string_view + operator"" _sv(char16_t const* s, std::size_t size) { + return sprout::basic_string_view(s, size); + } + inline SPROUT_CONSTEXPR sprout::basic_string_view + operator"" _sv(char32_t const* s, std::size_t size) { + return sprout::basic_string_view(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 diff --git a/sprout/uuid/udl.hpp b/sprout/uuid/udl.hpp index 47de8f7c..b830e63a 100644 --- a/sprout/uuid/udl.hpp +++ b/sprout/uuid/udl.hpp @@ -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