From 92c7169221259ecbb4ab344937d8ffaeffcad60c Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Sun, 14 Aug 2016 16:02:23 +0900 Subject: [PATCH] rename */udl.hpp -> literals.hpp [destructive] --- sprout/complex.hpp | 2 +- sprout/complex/{udl.hpp => literals.hpp} | 31 ++++----- sprout/complex/operators.hpp | 30 ++++----- sprout/cstddef.hpp | 15 +++++ sprout/cstddef/literals.hpp | 34 ++++++++++ sprout/detail/udl_namespace.hpp | 20 ++++++ sprout/functional/bind.hpp | 2 +- .../functional/bind/{udl.hpp => literals.hpp} | 15 ++--- sprout/index_tuple/{udl.hpp => literals.hpp} | 19 +++--- sprout/index_tuple/utility.hpp | 2 +- sprout/math/quaternion.hpp | 2 +- .../math/quaternion/{udl.hpp => literals.hpp} | 63 ++++++++++--------- sprout/random/random_result.hpp | 62 ++++++++++++------ sprout/random/variate_generator.hpp | 22 +++++-- sprout/rational.hpp | 2 +- sprout/rational/{udl.hpp => literals.hpp} | 31 ++++----- sprout/utility/string_view.hpp | 2 +- .../string_view/{udl.hpp => literals.hpp} | 15 ++--- sprout/utility/string_view/string_ref.hpp | 9 +-- sprout/uuid.hpp | 2 +- sprout/uuid/{udl.hpp => literals.hpp} | 23 +++---- testspr/header_all.hpp | 1 + 22 files changed, 259 insertions(+), 145 deletions(-) rename sprout/complex/{udl.hpp => literals.hpp} (64%) create mode 100644 sprout/cstddef.hpp create mode 100644 sprout/cstddef/literals.hpp create mode 100644 sprout/detail/udl_namespace.hpp rename sprout/functional/bind/{udl.hpp => literals.hpp} (80%) rename sprout/index_tuple/{udl.hpp => literals.hpp} (74%) rename sprout/math/quaternion/{udl.hpp => literals.hpp} (59%) rename sprout/rational/{udl.hpp => literals.hpp} (65%) rename sprout/utility/string_view/{udl.hpp => literals.hpp} (78%) rename sprout/uuid/{udl.hpp => literals.hpp} (89%) diff --git a/sprout/complex.hpp b/sprout/complex.hpp index a6630d96..12aba955 100644 --- a/sprout/complex.hpp +++ b/sprout/complex.hpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #endif // #ifndef SPROUT_COMPLEX_HPP diff --git a/sprout/complex/udl.hpp b/sprout/complex/literals.hpp similarity index 64% rename from sprout/complex/udl.hpp rename to sprout/complex/literals.hpp index 9221c226..4e03e312 100644 --- a/sprout/complex/udl.hpp +++ b/sprout/complex/literals.hpp @@ -5,16 +5,17 @@ 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_COMPLEX_UDL_HPP -#define SPROUT_COMPLEX_UDL_HPP +#ifndef SPROUT_COMPLEX_LITERALS_HPP +#define SPROUT_COMPLEX_LITERALS_HPP #include #include +#include #if SPROUT_USE_USER_DEFINED_LITERALS namespace sprout { - namespace udl { + namespace literals { namespace complex { // // _i @@ -51,20 +52,20 @@ namespace sprout { } } // namespace complex - using sprout::udl::complex::operator"" _i; - using sprout::udl::complex::operator"" _if; - using sprout::udl::complex::operator"" _iF; - using sprout::udl::complex::operator"" _il; - using sprout::udl::complex::operator"" _iL; - } // namespace udl + using sprout::literals::complex::operator"" _i; + using sprout::literals::complex::operator"" _if; + using sprout::literals::complex::operator"" _iF; + using sprout::literals::complex::operator"" _il; + using sprout::literals::complex::operator"" _iL; + } // namespace literals - using sprout::udl::complex::operator"" _i; - using sprout::udl::complex::operator"" _if; - using sprout::udl::complex::operator"" _iF; - using sprout::udl::complex::operator"" _il; - using sprout::udl::complex::operator"" _iL; + using sprout::literals::complex::operator"" _i; + using sprout::literals::complex::operator"" _if; + using sprout::literals::complex::operator"" _iF; + using sprout::literals::complex::operator"" _il; + using sprout::literals::complex::operator"" _iL; } // namespace sprout #endif // #if SPROUT_USE_USER_DEFINED_LITERALS -#endif // #ifndef SPROUT_COMPLEX_UDL_HPP +#endif // #ifndef SPROUT_COMPLEX_LITERALS_HPP diff --git a/sprout/complex/operators.hpp b/sprout/complex/operators.hpp index b65b7f1b..a1df3f74 100644 --- a/sprout/complex/operators.hpp +++ b/sprout/complex/operators.hpp @@ -1,15 +1,15 @@ -/*============================================================================= - 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_COMPLEX_OPERATORS_HPP -#define SPROUT_COMPLEX_OPERATORS_HPP - -#include -#include - -#endif // #ifndef SPROUT_COMPLEX_OPERATORS_HPP - +/*============================================================================= + 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_COMPLEX_OPERATORS_HPP +#define SPROUT_COMPLEX_OPERATORS_HPP + +#include +#include + +#endif // #ifndef SPROUT_COMPLEX_OPERATORS_HPP + diff --git a/sprout/cstddef.hpp b/sprout/cstddef.hpp new file mode 100644 index 00000000..f0e4b1d7 --- /dev/null +++ b/sprout/cstddef.hpp @@ -0,0 +1,15 @@ +/*============================================================================= + 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_CSTDDEF_HPP +#define SPROUT_CSTDDEF_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_CSTDDEF_HPP diff --git a/sprout/cstddef/literals.hpp b/sprout/cstddef/literals.hpp new file mode 100644 index 00000000..d1630d72 --- /dev/null +++ b/sprout/cstddef/literals.hpp @@ -0,0 +1,34 @@ +/*============================================================================= + 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_CSTDDEF_LITERALS_HPP +#define SPROUT_CSTDDEF_LITERALS_HPP + +#include +#include +#include + +#if SPROUT_USE_USER_DEFINED_LITERALS + +namespace sprout { + namespace literals { + namespace support_literals { + // + // operator"" _zu + // + SPROUT_CONSTEXPR std::size_t operator"" _zu(unsigned long long t) { + return static_cast(t); + } + } // namespace support_literals + + using sprout::literals::support_literals::operator"" _zu; + } // namespace literals +} // namespace sprout + +#endif // #if SPROUT_USE_USER_DEFINED_LITERALS + +#endif // #ifndef SPROUT_CSTDDEF_LITERALS_HPP diff --git a/sprout/detail/udl_namespace.hpp b/sprout/detail/udl_namespace.hpp new file mode 100644 index 00000000..c96a1c79 --- /dev/null +++ b/sprout/detail/udl_namespace.hpp @@ -0,0 +1,20 @@ +/*============================================================================= + 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_UDL_NAMESPACE_HPP +#define SPROUT_DETAIL_UDL_NAMESPACE_HPP + +#include + +namespace sprout { + namespace literals { + } // namespace literals + + namespace udl = sprout::literals; +} // namespace sprout + +#endif // #ifndef SPROUT_DETAIL_UDL_NAMESPACE_HPP diff --git a/sprout/functional/bind.hpp b/sprout/functional/bind.hpp index e417efd8..169f46af 100644 --- a/sprout/functional/bind.hpp +++ b/sprout/functional/bind.hpp @@ -11,6 +11,6 @@ #include #include #include -#include +#include #endif // #ifndef SPROUT_FUNCTIONAL_BIND_HPP diff --git a/sprout/functional/bind/udl.hpp b/sprout/functional/bind/literals.hpp similarity index 80% rename from sprout/functional/bind/udl.hpp rename to sprout/functional/bind/literals.hpp index 99e3cebc..5f333d3d 100644 --- a/sprout/functional/bind/udl.hpp +++ b/sprout/functional/bind/literals.hpp @@ -5,11 +5,12 @@ 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_FUNCTIONAL_BIND_UDL_HPP -#define SPROUT_FUNCTIONAL_BIND_UDL_HPP +#ifndef SPROUT_FUNCTIONAL_BIND_LITERALS_HPP +#define SPROUT_FUNCTIONAL_BIND_LITERALS_HPP #include #include +#include #if SPROUT_USE_USER_DEFINED_LITERALS @@ -34,7 +35,7 @@ namespace sprout { > {}; - namespace udl { + namespace literals { namespace placeholders { // // _ @@ -54,11 +55,11 @@ namespace sprout { } } // namespace placeholders - using sprout::udl::placeholders::operator"" _; - using sprout::udl::placeholders::operator"" _tail; - } // namespace udl + using sprout::literals::placeholders::operator"" _; + using sprout::literals::placeholders::operator"" _tail; + } // namespace literals } // namespace sprout #endif // #if SPROUT_USE_USER_DEFINED_LITERALS -#endif // #ifndef SPROUT_FUNCTIONAL_BIND_UDL_HPP +#endif // #ifndef SPROUT_FUNCTIONAL_BIND_LITERALS_HPP diff --git a/sprout/index_tuple/udl.hpp b/sprout/index_tuple/literals.hpp similarity index 74% rename from sprout/index_tuple/udl.hpp rename to sprout/index_tuple/literals.hpp index 06a0c6ed..50e50f19 100644 --- a/sprout/index_tuple/udl.hpp +++ b/sprout/index_tuple/literals.hpp @@ -5,11 +5,12 @@ 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_INDEX_TUPLE_UDL_HPP -#define SPROUT_INDEX_TUPLE_UDL_HPP +#ifndef SPROUT_INDEX_TUPLE_LITERALS_HPP +#define SPROUT_INDEX_TUPLE_LITERALS_HPP #include #include +#include #if SPROUT_USE_USER_DEFINED_LITERALS @@ -30,7 +31,7 @@ namespace sprout { : public sprout::make_uindex_tuple::value> {}; - namespace udl { + namespace literals { namespace indexes { // // _indexes @@ -48,14 +49,14 @@ namespace sprout { } } // namespace indexes - using sprout::udl::indexes::operator"" _indexes; - using sprout::udl::indexes::operator"" _uindexes; - } // namespace udl + using sprout::literals::indexes::operator"" _indexes; + using sprout::literals::indexes::operator"" _uindexes; + } // namespace literals - using sprout::udl::indexes::operator"" _indexes; - using sprout::udl::indexes::operator"" _uindexes; + using sprout::literals::indexes::operator"" _indexes; + using sprout::literals::indexes::operator"" _uindexes; } // namespace sprout #endif // #if SPROUT_USE_USER_DEFINED_LITERALS -#endif // #ifndef SPROUT_INDEX_TUPLE_UDL_HPP +#endif // #ifndef SPROUT_INDEX_TUPLE_LITERALS_HPP diff --git a/sprout/index_tuple/utility.hpp b/sprout/index_tuple/utility.hpp index c585ad01..21c0b349 100644 --- a/sprout/index_tuple/utility.hpp +++ b/sprout/index_tuple/utility.hpp @@ -11,6 +11,6 @@ #include #include #include -#include +#include #endif // #ifndef SPROUT_INDEX_TUPLE_UTILITY_HPP diff --git a/sprout/math/quaternion.hpp b/sprout/math/quaternion.hpp index afbd527b..f33d3995 100644 --- a/sprout/math/quaternion.hpp +++ b/sprout/math/quaternion.hpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #endif // #ifndef SPROUT_MATH_QUATERNION_HPP diff --git a/sprout/math/quaternion/udl.hpp b/sprout/math/quaternion/literals.hpp similarity index 59% rename from sprout/math/quaternion/udl.hpp rename to sprout/math/quaternion/literals.hpp index bbe625d8..0e923184 100644 --- a/sprout/math/quaternion/udl.hpp +++ b/sprout/math/quaternion/literals.hpp @@ -5,23 +5,24 @@ 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_MATH_QUATERNION_UDL_HPP -#define SPROUT_MATH_QUATERNION_UDL_HPP +#ifndef SPROUT_MATH_QUATERNION_LITERALS_HPP +#define SPROUT_MATH_QUATERNION_LITERALS_HPP #include -#include +#include #include +#include #if SPROUT_USE_USER_DEFINED_LITERALS namespace sprout { - namespace udl { + namespace literals { namespace quaternion { - using sprout::udl::complex::operator"" _i; - using sprout::udl::complex::operator"" _if; - using sprout::udl::complex::operator"" _iF; - using sprout::udl::complex::operator"" _il; - using sprout::udl::complex::operator"" _iL; + using sprout::literals::complex::operator"" _i; + using sprout::literals::complex::operator"" _if; + using sprout::literals::complex::operator"" _iF; + using sprout::literals::complex::operator"" _il; + using sprout::literals::complex::operator"" _iL; // // _j @@ -92,32 +93,32 @@ namespace sprout { } } // namespace quaternion - using sprout::udl::quaternion::operator"" _j; - using sprout::udl::quaternion::operator"" _jf; - using sprout::udl::quaternion::operator"" _jF; - using sprout::udl::quaternion::operator"" _jl; - using sprout::udl::quaternion::operator"" _jL; + using sprout::literals::quaternion::operator"" _j; + using sprout::literals::quaternion::operator"" _jf; + using sprout::literals::quaternion::operator"" _jF; + using sprout::literals::quaternion::operator"" _jl; + using sprout::literals::quaternion::operator"" _jL; - using sprout::udl::quaternion::operator"" _k; - using sprout::udl::quaternion::operator"" _kf; - using sprout::udl::quaternion::operator"" _kF; - using sprout::udl::quaternion::operator"" _kl; - using sprout::udl::quaternion::operator"" _kL; - } // namespace udl + using sprout::literals::quaternion::operator"" _k; + using sprout::literals::quaternion::operator"" _kf; + using sprout::literals::quaternion::operator"" _kF; + using sprout::literals::quaternion::operator"" _kl; + using sprout::literals::quaternion::operator"" _kL; + } // namespace literals - using sprout::udl::quaternion::operator"" _j; - using sprout::udl::quaternion::operator"" _jf; - using sprout::udl::quaternion::operator"" _jF; - using sprout::udl::quaternion::operator"" _jl; - using sprout::udl::quaternion::operator"" _jL; + using sprout::literals::quaternion::operator"" _j; + using sprout::literals::quaternion::operator"" _jf; + using sprout::literals::quaternion::operator"" _jF; + using sprout::literals::quaternion::operator"" _jl; + using sprout::literals::quaternion::operator"" _jL; - using sprout::udl::quaternion::operator"" _k; - using sprout::udl::quaternion::operator"" _kf; - using sprout::udl::quaternion::operator"" _kF; - using sprout::udl::quaternion::operator"" _kl; - using sprout::udl::quaternion::operator"" _kL; + using sprout::literals::quaternion::operator"" _k; + using sprout::literals::quaternion::operator"" _kf; + using sprout::literals::quaternion::operator"" _kF; + using sprout::literals::quaternion::operator"" _kl; + using sprout::literals::quaternion::operator"" _kL; } // namespace sprout #endif // #if SPROUT_USE_USER_DEFINED_LITERALS -#endif // #ifndef SPROUT_MATH_QUATERNION_UDL_HPP +#endif // #ifndef SPROUT_MATH_QUATERNION_LITERALS_HPP diff --git a/sprout/random/random_result.hpp b/sprout/random/random_result.hpp index 80bf2369..19ceb8b7 100644 --- a/sprout/random/random_result.hpp +++ b/sprout/random/random_result.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -37,16 +38,16 @@ namespace sprout { > : public std::iterator< std::input_iterator_tag, - typename Distribution::result_type, + typename std::remove_reference::type::result_type, std::ptrdiff_t, - typename Distribution::result_type const*, - typename Distribution::result_type const& + typename std::remove_reference::type::result_type const*, + typename std::remove_reference::type::result_type const& > { public: typedef Engine engine_type; typedef Distribution distribution_type; - typedef typename distribution_type::result_type result_type; + typedef typename std::remove_reference::type::result_type result_type; typedef sprout::random::variate_generator generator_type; private: typedef std::iterator< @@ -56,12 +57,23 @@ namespace sprout { result_type const*, result_type const& > base_type; + typedef sprout::random::detail::ptr_helper engine_helper_type; + typedef sprout::random::detail::ptr_helper distribution_helper_type; public: typedef typename base_type::iterator_category iterator_category; typedef typename base_type::value_type value_type; typedef typename base_type::difference_type difference_type; typedef typename base_type::pointer pointer; typedef typename base_type::reference reference; + typedef typename engine_helper_type::value_type engine_value_type; + typedef typename distribution_helper_type::value_type distribution_value_type; + typedef typename engine_helper_type::reference_type engine_reference_type; + typedef typename distribution_helper_type::reference_type distribution_reference_type; + typedef typename engine_helper_type::const_reference_type engine_const_reference_type; + typedef typename distribution_helper_type::const_reference_type distribution_const_reference_type; + typedef typename engine_helper_type::rvalue_type engine_param_type; + typedef typename distribution_helper_type::rvalue_type distribution_param_type; + typedef typename generator_type::random_result_type random_result_type; private: result_type result_; generator_type generator_; @@ -71,13 +83,13 @@ namespace sprout { {} random_result(random_result const&) = default; SPROUT_CONSTEXPR random_result( - result_type result, - engine_type const& engine, distribution_type const& distribution + result_type const& result, + engine_param_type engine, distribution_param_type distribution ) : result_(result) , generator_(engine, distribution) {} - SPROUT_CONSTEXPR random_result operator()() const { + SPROUT_CONSTEXPR random_result_type operator()() const { return generator_(); } SPROUT_CXX14_CONSTEXPR result_type& generated_value() SPROUT_NOEXCEPT { @@ -92,6 +104,9 @@ namespace sprout { SPROUT_CONSTEXPR generator_type const& next_generator() const SPROUT_NOEXCEPT { return generator_; } + SPROUT_CONSTEXPR random_result_type next_value() const SPROUT_NOEXCEPT { + return generator_(); + } SPROUT_CXX14_CONSTEXPR result_type& result() SPROUT_NOEXCEPT { return result_; } @@ -104,16 +119,16 @@ namespace sprout { SPROUT_CONSTEXPR generator_type const& next() const SPROUT_NOEXCEPT { return generator_; } - SPROUT_CXX14_CONSTEXPR engine_type& engine() SPROUT_NOEXCEPT { + SPROUT_CXX14_CONSTEXPR engine_reference_type engine() SPROUT_NOEXCEPT { return generator_.engine(); } - SPROUT_CONSTEXPR engine_type const& engine() const SPROUT_NOEXCEPT { + SPROUT_CONSTEXPR engine_const_reference_type engine() const SPROUT_NOEXCEPT { return generator_.engine(); } - SPROUT_CXX14_CONSTEXPR distribution_type& distribution() SPROUT_NOEXCEPT { + SPROUT_CXX14_CONSTEXPR distribution_reference_type distribution() SPROUT_NOEXCEPT { return generator_.distribution(); } - SPROUT_CONSTEXPR distribution_type const& distribution() const SPROUT_NOEXCEPT { + SPROUT_CONSTEXPR distribution_const_reference_type distribution() const SPROUT_NOEXCEPT { return generator_.distribution(); } SPROUT_CXX14_CONSTEXPR operator result_type&() SPROUT_NOEXCEPT { @@ -170,15 +185,15 @@ namespace sprout { > : public std::iterator< std::input_iterator_tag, - typename Engine::result_type, + typename std::remove_reference::type::result_type, std::ptrdiff_t, - typename Engine::result_type const*, - typename Engine::result_type const& + typename std::remove_reference::type::result_type const*, + typename std::remove_reference::type::result_type const& > { public: typedef Engine engine_type; - typedef typename engine_type::result_type result_type; + typedef typename std::remove_reference::type::result_type result_type; typedef engine_type generator_type; private: typedef std::iterator< @@ -188,12 +203,18 @@ namespace sprout { result_type const*, result_type const& > base_type; + typedef sprout::random::detail::ptr_helper engine_helper_type; public: typedef typename base_type::iterator_category iterator_category; typedef typename base_type::value_type value_type; typedef typename base_type::difference_type difference_type; typedef typename base_type::pointer pointer; typedef typename base_type::reference reference; + typedef typename engine_helper_type::value_type engine_value_type; + typedef typename engine_helper_type::reference_type engine_reference_type; + typedef typename engine_helper_type::const_reference_type engine_const_reference_type; + typedef typename engine_helper_type::rvalue_type engine_param_type; + typedef random_result random_result_type; private: result_type result_; generator_type generator_; @@ -202,10 +223,10 @@ namespace sprout { : result_(), generator_() {} random_result(random_result const&) = default; - SPROUT_CONSTEXPR random_result(result_type result, engine_type const& engine) + SPROUT_CONSTEXPR random_result(result_type result, engine_param_type engine) : result_(result), generator_(engine) {} - SPROUT_CONSTEXPR random_result operator()() const { + SPROUT_CONSTEXPR random_result_type operator()() const { return generator_(); } SPROUT_CXX14_CONSTEXPR result_type& generated_value() SPROUT_NOEXCEPT { @@ -220,6 +241,9 @@ namespace sprout { SPROUT_CONSTEXPR generator_type const& next_generator() const SPROUT_NOEXCEPT { return generator_; } + SPROUT_CONSTEXPR random_result_type next_value() const SPROUT_NOEXCEPT { + return generator_(); + } SPROUT_CXX14_CONSTEXPR result_type& result() SPROUT_NOEXCEPT { return result_; } @@ -232,10 +256,10 @@ namespace sprout { SPROUT_CONSTEXPR generator_type const& next() const SPROUT_NOEXCEPT { return generator_; } - SPROUT_CXX14_CONSTEXPR engine_type& engine() SPROUT_NOEXCEPT { + SPROUT_CXX14_CONSTEXPR engine_reference_type engine() SPROUT_NOEXCEPT { return generator_; } - SPROUT_CONSTEXPR engine_type const& engine() const SPROUT_NOEXCEPT { + SPROUT_CONSTEXPR engine_const_reference_type engine() const SPROUT_NOEXCEPT { return generator_; } SPROUT_CXX14_CONSTEXPR operator result_type&() SPROUT_NOEXCEPT { diff --git a/sprout/random/variate_generator.hpp b/sprout/random/variate_generator.hpp index c29d62c5..8dc5889b 100644 --- a/sprout/random/variate_generator.hpp +++ b/sprout/random/variate_generator.hpp @@ -14,6 +14,7 @@ #include #include #include +#include #include namespace sprout { @@ -41,9 +42,16 @@ namespace sprout { typedef typename distribution_value_type::result_type result_type; typedef typename std::conditional< std::is_reference::value && !std::is_const::type>::value, - result_type, + sprout::random::random_result, sprout::random::random_result >::type random_result_type; + private: + static SPROUT_CONSTEXPR random_result_type call(variate_generator const& g, sprout::true_type) { + return random_result_type(g.distribution_(g.engine_), g.distribution_, g.engine_); + } + static SPROUT_CONSTEXPR random_result_type call(variate_generator const& g, sprout::false_type) { + return g.distribution_(sprout::as_const(g.engine_)); + } private: engine_type engine_; distribution_type distribution_; @@ -60,16 +68,20 @@ namespace sprout { : engine_(engine) , distribution_(distribution) {} - SPROUT_CONSTEXPR random_result_type const operator()() const { - return distribution_(engine_); + SPROUT_CONSTEXPR random_result_type operator()() const { + typedef sprout::bool_constant::value && !std::is_const::type>::value> tag; + return call(*this, tag()); } - engine_reference_type engine() SPROUT_NOEXCEPT { + SPROUT_CONSTEXPR random_result_type next_value() const { + return (*this)(); + } + SPROUT_CXX14_CONSTEXPR engine_reference_type engine() SPROUT_NOEXCEPT { return engine_helper_type::ref(engine_); } SPROUT_CONSTEXPR engine_const_reference_type engine() const SPROUT_NOEXCEPT { return engine_helper_type::ref(engine_); } - distribution_reference_type distribution() SPROUT_NOEXCEPT { + SPROUT_CXX14_CONSTEXPR distribution_reference_type distribution() SPROUT_NOEXCEPT { return distribution_helper_type::ref(distribution_); } SPROUT_CONSTEXPR distribution_const_reference_type distribution() const SPROUT_NOEXCEPT { diff --git a/sprout/rational.hpp b/sprout/rational.hpp index e60e6622..2bf0b510 100644 --- a/sprout/rational.hpp +++ b/sprout/rational.hpp @@ -19,6 +19,6 @@ #include #include #include -#include +#include #endif // #ifndef SPROUT_RATIONAL_HPP diff --git a/sprout/rational/udl.hpp b/sprout/rational/literals.hpp similarity index 65% rename from sprout/rational/udl.hpp rename to sprout/rational/literals.hpp index be74f0b6..986ee8f4 100644 --- a/sprout/rational/udl.hpp +++ b/sprout/rational/literals.hpp @@ -5,16 +5,17 @@ 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_RATIONAL_UDL_HPP -#define SPROUT_RATIONAL_UDL_HPP +#ifndef SPROUT_RATIONAL_LITERALS_HPP +#define SPROUT_RATIONAL_LITERALS_HPP #include #include +#include #if SPROUT_USE_USER_DEFINED_LITERALS namespace sprout { - namespace udl { + namespace literals { namespace rational { // // _r @@ -51,20 +52,20 @@ namespace sprout { } } // namespace rational - using sprout::udl::rational::operator"" _r; - using sprout::udl::rational::operator"" _rl; - using sprout::udl::rational::operator"" _rL; - using sprout::udl::rational::operator"" _rll; - using sprout::udl::rational::operator"" _rLL; - } // namespace udl + using sprout::literals::rational::operator"" _r; + using sprout::literals::rational::operator"" _rl; + using sprout::literals::rational::operator"" _rL; + using sprout::literals::rational::operator"" _rll; + using sprout::literals::rational::operator"" _rLL; + } // namespace literals - using sprout::udl::rational::operator"" _r; - using sprout::udl::rational::operator"" _rl; - using sprout::udl::rational::operator"" _rL; - using sprout::udl::rational::operator"" _rll; - using sprout::udl::rational::operator"" _rLL; + using sprout::literals::rational::operator"" _r; + using sprout::literals::rational::operator"" _rl; + using sprout::literals::rational::operator"" _rL; + using sprout::literals::rational::operator"" _rll; + using sprout::literals::rational::operator"" _rLL; } // namespace sprout #endif // #if SPROUT_USE_USER_DEFINED_LITERALS -#endif // #ifndef SPROUT_RATIONAL_UDL_HPP +#endif // #ifndef SPROUT_RATIONAL_LITERALS_HPP diff --git a/sprout/utility/string_view.hpp b/sprout/utility/string_view.hpp index c772d84d..39936be1 100644 --- a/sprout/utility/string_view.hpp +++ b/sprout/utility/string_view.hpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #endif // #ifndef SPROUT_UTILITY_STRING_VIEW_HPP diff --git a/sprout/utility/string_view/udl.hpp b/sprout/utility/string_view/literals.hpp similarity index 78% rename from sprout/utility/string_view/udl.hpp rename to sprout/utility/string_view/literals.hpp index e6358221..42b673dd 100644 --- a/sprout/utility/string_view/udl.hpp +++ b/sprout/utility/string_view/literals.hpp @@ -5,18 +5,19 @@ 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_UTILITY_STRING_VIEW_UDL_HPP -#define SPROUT_UTILITY_STRING_VIEW_UDL_HPP +#ifndef SPROUT_UTILITY_STRING_VIEW_LITERALS_HPP +#define SPROUT_UTILITY_STRING_VIEW_LITERALS_HPP #include #include +#include #if SPROUT_USE_USER_DEFINED_LITERALS #include namespace sprout { - namespace udl { + namespace literals { namespace strings { // // _sv @@ -41,12 +42,12 @@ namespace sprout { #endif } // namespace strings - using sprout::udl::strings::operator"" _sv; - } // namespace udl + using sprout::literals::strings::operator"" _sv; + } // namespace literals - using sprout::udl::strings::operator"" _sv; + using sprout::literals::strings::operator"" _sv; } // namespace sprout #endif // #if SPROUT_USE_USER_DEFINED_LITERALS -#endif // #ifndef SPROUT_UTILITY_STRING_VIEW_UDL_HPP +#endif // #ifndef SPROUT_UTILITY_STRING_VIEW_LITERALS_HPP diff --git a/sprout/utility/string_view/string_ref.hpp b/sprout/utility/string_view/string_ref.hpp index 921a5f2f..605583aa 100644 --- a/sprout/utility/string_view/string_ref.hpp +++ b/sprout/utility/string_view/string_ref.hpp @@ -12,6 +12,7 @@ #include #include #include +#include namespace sprout { // @@ -159,7 +160,7 @@ namespace sprout { #endif #endif // #if SPROUT_USE_VARIABLE_TEMPLATES - namespace udl { + namespace literals { namespace strings { // // _sr @@ -184,10 +185,10 @@ namespace sprout { #endif } // namespace strings - using sprout::udl::strings::operator"" _sr; - } // namespace udl + using sprout::literals::strings::operator"" _sr; + } // namespace literals - using sprout::udl::strings::operator"" _sr; + using sprout::literals::strings::operator"" _sr; } // namespace sprout #endif // #ifndef SPROUT_UTILITY_STRING_VIEW_STRING_REF_HPP diff --git a/sprout/uuid.hpp b/sprout/uuid.hpp index 8327a06f..1a208829 100644 --- a/sprout/uuid.hpp +++ b/sprout/uuid.hpp @@ -15,6 +15,6 @@ #include #include #include -#include +#include #endif // #ifndef SPROUT_UUID_HPP diff --git a/sprout/uuid/udl.hpp b/sprout/uuid/literals.hpp similarity index 89% rename from sprout/uuid/udl.hpp rename to sprout/uuid/literals.hpp index b830e63a..3caed341 100644 --- a/sprout/uuid/udl.hpp +++ b/sprout/uuid/literals.hpp @@ -5,11 +5,12 @@ 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_UUID_UDL_HPP -#define SPROUT_UUID_UDL_HPP +#ifndef SPROUT_UUID_LITERALS_HPP +#define SPROUT_UUID_LITERALS_HPP #include #include +#include #if SPROUT_USE_USER_DEFINED_LITERALS @@ -61,7 +62,7 @@ namespace sprout { } // namespace detail } // namespace uuids - namespace udl { + namespace literals { namespace uuids { // // _uuid @@ -130,16 +131,16 @@ namespace sprout { #endif } // namespace uuids - using sprout::udl::uuids::operator"" _uuid; - using sprout::udl::uuids::operator"" _uuid3; - using sprout::udl::uuids::operator"" _uuid5; - } // namespace udl + using sprout::literals::uuids::operator"" _uuid; + using sprout::literals::uuids::operator"" _uuid3; + using sprout::literals::uuids::operator"" _uuid5; + } // namespace literals - using sprout::udl::uuids::operator"" _uuid; - using sprout::udl::uuids::operator"" _uuid3; - using sprout::udl::uuids::operator"" _uuid5; + using sprout::literals::uuids::operator"" _uuid; + using sprout::literals::uuids::operator"" _uuid3; + using sprout::literals::uuids::operator"" _uuid5; } // namespace sprout #endif // #if SPROUT_USE_USER_DEFINED_LITERALS -#endif // #ifndef SPROUT_UUID_UDL_HPP +#endif // #ifndef SPROUT_UUID_LITERALS_HPP diff --git a/testspr/header_all.hpp b/testspr/header_all.hpp index 219acf4e..434485ad 100644 --- a/testspr/header_all.hpp +++ b/testspr/header_all.hpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include