diff --git a/sprout/auto_config.hpp b/sprout/auto_config.hpp index cfb54dda..268962ee 100644 --- a/sprout/auto_config.hpp +++ b/sprout/auto_config.hpp @@ -39,6 +39,10 @@ # endif // #ifdef BOOST_NO_TEMPLATE_ALIASES #endif // #ifndef SPROUT_CONFIG_DISABLE_TEMPLATE_ALIASES +// +// SPROUT_USE_USER_DEFINED_LITERALS +// + // // SPROUT_CONFIG_USE_SSCRISK_CEL // diff --git a/sprout/config.hpp b/sprout/config.hpp index b22aa4ee..55a57a65 100644 --- a/sprout/config.hpp +++ b/sprout/config.hpp @@ -23,6 +23,12 @@ # define SPROUT_USE_TEMPLATE_ALIASES 0 #endif // #ifndef SPROUT_CONFIG_DISABLE_TEMPLATE_ALIASES +#ifndef SPROUT_CONFIG_DISABLE_USER_DEFINED_LITERALS +# define SPROUT_USE_USER_DEFINED_LITERALS 1 +#else // #ifndef SPROUT_CONFIG_DISABLE_USER_DEFINED_LITERALS +# define SPROUT_USE_USER_DEFINED_LITERALS 0 +#endif // #ifndef SPROUT_CONFIG_DISABLE_USER_DEFINED_LITERALS + #ifndef SPROUT_CONFIG_USE_SSCRISK_CEL # define HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL # define HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL diff --git a/sprout/uuid.hpp b/sprout/uuid.hpp index dc212f4b..14267ba3 100644 --- a/sprout/uuid.hpp +++ b/sprout/uuid.hpp @@ -6,5 +6,6 @@ #include #include #include +#include #endif // #ifndef SPROUT_UUID_HPP diff --git a/sprout/uuid/string_generator.hpp b/sprout/uuid/string_generator.hpp index a6d7d4e3..df9d6b36 100644 --- a/sprout/uuid/string_generator.hpp +++ b/sprout/uuid/string_generator.hpp @@ -168,6 +168,10 @@ namespace sprout { ; } public: + template + SPROUT_CONSTEXPR result_type operator()(Iterator first, Iterator last) const { + return generate_1(next_char(first, last)); + } template SPROUT_CONSTEXPR result_type operator()(sprout::basic_string const& s) const { return operator()(s.begin(), s.end()); @@ -184,10 +188,6 @@ namespace sprout { SPROUT_CONSTEXPR result_type operator()(char32_t const* s) const { return operator()(s, s + sprout::char_traits::length(s)); } - template - SPROUT_CONSTEXPR result_type operator()(Iterator first, Iterator last) const { - return generate_1(next_char(first, last)); - } }; } // namespace uuids } // namespace sprout diff --git a/sprout/uuid/udl.hpp b/sprout/uuid/udl.hpp new file mode 100644 index 00000000..0d11c924 --- /dev/null +++ b/sprout/uuid/udl.hpp @@ -0,0 +1,40 @@ +#ifndef SPROUT_UUID_UDL_HPP +#define SPROUT_UUID_UDL_HPP + +#include +#include + +#if SPROUT_USE_USER_DEFINED_LITERALS + +#include +#include + +namespace sprout { + namespace uuids { + namespace udl { + // + // _uuid + // + SPROUT_CONSTEXPR sprout::uuids::uuid operator "" _uuid(char const* s, std::size_t) { + return sprout::uuids::string_generator()(s); + } + SPROUT_CONSTEXPR sprout::uuids::uuid operator "" _uuid(wchar_t const* s, std::size_t) { + return sprout::uuids::string_generator()(s); + } + SPROUT_CONSTEXPR sprout::uuids::uuid operator "" _uuid(char16_t const* s, std::size_t) { + return sprout::uuids::string_generator()(s); + } + SPROUT_CONSTEXPR sprout::uuids::uuid operator "" _uuid(char32_t const* s, std::size_t) { + return sprout::uuids::string_generator()(s); + } + } // namespace uuids + + using sprout::uuids::udl::operator "" _uuid; + } // namespace udl + + using sprout::uuids::udl::operator "" _uuid; +} // namespace sprout + +#endif // #if SPROUT_USE_USER_DEFINED_LITERALS + +#endif // #ifndef SPROUT_UUID_UDL_HPP