add User defined literal sprout::uuids::udl::_uuid

fix sprout::uuid::string_generator
This commit is contained in:
bolero-MURAKAMI 2012-03-18 22:04:09 +09:00
parent dacf1f40ac
commit d7fbadb62c
5 changed files with 55 additions and 4 deletions

View file

@ -39,6 +39,10 @@
# endif // #ifdef BOOST_NO_TEMPLATE_ALIASES # endif // #ifdef BOOST_NO_TEMPLATE_ALIASES
#endif // #ifndef SPROUT_CONFIG_DISABLE_TEMPLATE_ALIASES #endif // #ifndef SPROUT_CONFIG_DISABLE_TEMPLATE_ALIASES
//
// SPROUT_USE_USER_DEFINED_LITERALS
//
// //
// SPROUT_CONFIG_USE_SSCRISK_CEL // SPROUT_CONFIG_USE_SSCRISK_CEL
// //

View file

@ -23,6 +23,12 @@
# define SPROUT_USE_TEMPLATE_ALIASES 0 # define SPROUT_USE_TEMPLATE_ALIASES 0
#endif // #ifndef SPROUT_CONFIG_DISABLE_TEMPLATE_ALIASES #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 #ifndef SPROUT_CONFIG_USE_SSCRISK_CEL
# define HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL <sprout/detail/functional.hpp> # define HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT_DETAIL <sprout/detail/functional.hpp>
# define HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL <sprout/detail/algorithm.hpp> # define HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL <sprout/detail/algorithm.hpp>

View file

@ -6,5 +6,6 @@
#include <sprout/uuid/uuid_io.hpp> #include <sprout/uuid/uuid_io.hpp>
#include <sprout/uuid/uuid_hash.hpp> #include <sprout/uuid/uuid_hash.hpp>
#include <sprout/uuid/uuid_generators.hpp> #include <sprout/uuid/uuid_generators.hpp>
#include <sprout/uuid/udl.hpp>
#endif // #ifndef SPROUT_UUID_HPP #endif // #ifndef SPROUT_UUID_HPP

View file

@ -168,6 +168,10 @@ namespace sprout {
; ;
} }
public: public:
template<typename Iterator>
SPROUT_CONSTEXPR result_type operator()(Iterator first, Iterator last) const {
return generate_1(next_char<Iterator>(first, last));
}
template<typename Elem, std::size_t N, typename Traits> template<typename Elem, std::size_t N, typename Traits>
SPROUT_CONSTEXPR result_type operator()(sprout::basic_string<Elem, N, Traits> const& s) const { SPROUT_CONSTEXPR result_type operator()(sprout::basic_string<Elem, N, Traits> const& s) const {
return operator()(s.begin(), s.end()); return operator()(s.begin(), s.end());
@ -184,10 +188,6 @@ namespace sprout {
SPROUT_CONSTEXPR result_type operator()(char32_t const* s) const { SPROUT_CONSTEXPR result_type operator()(char32_t const* s) const {
return operator()(s, s + sprout::char_traits<char32_t>::length(s)); return operator()(s, s + sprout::char_traits<char32_t>::length(s));
} }
template<typename Iterator>
SPROUT_CONSTEXPR result_type operator()(Iterator first, Iterator last) const {
return generate_1(next_char<Iterator>(first, last));
}
}; };
} // namespace uuids } // namespace uuids
} // namespace sprout } // namespace sprout

40
sprout/uuid/udl.hpp Normal file
View file

@ -0,0 +1,40 @@
#ifndef SPROUT_UUID_UDL_HPP
#define SPROUT_UUID_UDL_HPP
#include <sprout/config.hpp>
#include <sprout/uuid/uuid.hpp>
#if SPROUT_USE_USER_DEFINED_LITERALS
#include <cstddef>
#include <sprout/uuid/string_generator.hpp>
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