mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-11-14 10:39:05 +00:00
add user-defined literals complex, rational
This commit is contained in:
parent
9e9556b62a
commit
94b146b5cc
7 changed files with 167 additions and 26 deletions
|
@ -69,7 +69,7 @@ namespace sprout {
|
|||
//
|
||||
void
|
||||
assertion_failed(sprout::assertion_info const&);
|
||||
} // namespace sprout_adl
|
||||
} // namespace sprout
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
|
@ -166,7 +166,7 @@ namespace sprout {
|
|||
//
|
||||
void
|
||||
assertion_failed_msg(sprout::assertion_info_msg const&);
|
||||
} // namespace sprout_adl
|
||||
} // namespace sprout
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
|
|
|
@ -8,5 +8,6 @@
|
|||
#include <sprout/complex/transcendentals.hpp>
|
||||
#include <sprout/complex/hash.hpp>
|
||||
#include <sprout/complex/nearest.hpp>
|
||||
#include <sprout/complex/udl.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_COMPLEX_HPP
|
||||
|
|
63
sprout/complex/udl.hpp
Normal file
63
sprout/complex/udl.hpp
Normal file
|
@ -0,0 +1,63 @@
|
|||
#ifndef SPROUT_COMPLEX_UDL_HPP
|
||||
#define SPROUT_COMPLEX_UDL_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/complex/complex.hpp>
|
||||
|
||||
#if SPROUT_USE_USER_DEFINED_LITERALS
|
||||
|
||||
namespace sprout {
|
||||
namespace udl {
|
||||
namespace complex {
|
||||
//
|
||||
// _i
|
||||
//
|
||||
inline SPROUT_CONSTEXPR sprout::complex<double>
|
||||
operator"" _i(long double x) {
|
||||
return sprout::complex<double>(0, x);
|
||||
}
|
||||
|
||||
//
|
||||
// _if
|
||||
// _iF
|
||||
//
|
||||
inline SPROUT_CONSTEXPR sprout::complex<float>
|
||||
operator"" _if(long double x) {
|
||||
return sprout::complex<float>(0, x);
|
||||
}
|
||||
inline SPROUT_CONSTEXPR sprout::complex<float>
|
||||
operator"" _iF(long double x) {
|
||||
return sprout::complex<float>(0, x);
|
||||
}
|
||||
|
||||
//
|
||||
// _il
|
||||
// _iL
|
||||
//
|
||||
inline SPROUT_CONSTEXPR sprout::complex<long double>
|
||||
operator"" _il(long double x) {
|
||||
return sprout::complex<long double>(0, x);
|
||||
}
|
||||
inline SPROUT_CONSTEXPR sprout::complex<long double>
|
||||
operator"" _iL(long double x) {
|
||||
return sprout::complex<long double>(0, x);
|
||||
}
|
||||
} // 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::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 sprout
|
||||
|
||||
#endif // #if SPROUT_USE_USER_DEFINED_LITERALS
|
||||
|
||||
#endif // #ifndef SPROUT_COMPLEX_UDL_HPP
|
|
@ -39,27 +39,32 @@ namespace sprout {
|
|||
{};
|
||||
|
||||
namespace udl {
|
||||
//
|
||||
// _indexes
|
||||
//
|
||||
template<char... Chars>
|
||||
SPROUT_CONSTEXPR typename sprout::indexes_result<Chars...>::type
|
||||
operator "" _indexes() {
|
||||
return sprout::indexes_result<Chars...>::make();
|
||||
}
|
||||
namespace indexes {
|
||||
//
|
||||
// _indexes
|
||||
//
|
||||
template<char... Chars>
|
||||
SPROUT_CONSTEXPR typename sprout::indexes_result<Chars...>::type
|
||||
operator"" _indexes() {
|
||||
return sprout::indexes_result<Chars...>::make();
|
||||
}
|
||||
|
||||
//
|
||||
// _uindexes
|
||||
//
|
||||
template<char... Chars>
|
||||
SPROUT_CONSTEXPR typename sprout::uindexes_result<Chars...>::type
|
||||
operator "" _uindexes() {
|
||||
return sprout::uindexes_result<Chars...>::make();
|
||||
}
|
||||
//
|
||||
// _uindexes
|
||||
//
|
||||
template<char... Chars>
|
||||
SPROUT_CONSTEXPR typename sprout::uindexes_result<Chars...>::type
|
||||
operator"" _uindexes() {
|
||||
return sprout::uindexes_result<Chars...>::make();
|
||||
}
|
||||
} // namespace indexes
|
||||
|
||||
using sprout::udl::indexes::operator"" _indexes;
|
||||
using sprout::udl::indexes::operator"" _uindexes;
|
||||
} // namespace udl
|
||||
|
||||
using sprout::udl::operator "" _indexes;
|
||||
using sprout::udl::operator "" _uindexes;
|
||||
using sprout::udl::indexes::operator"" _indexes;
|
||||
using sprout::udl::indexes::operator"" _uindexes;
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #if SPROUT_USE_USER_DEFINED_LITERALS
|
||||
|
|
|
@ -10,5 +10,6 @@
|
|||
#include <sprout/rational/values.hpp>
|
||||
#include <sprout/rational/conversion.hpp>
|
||||
#include <sprout/rational/exceptions.hpp>
|
||||
#include <sprout/rational/udl.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_RATIONAL_HPP
|
||||
|
|
63
sprout/rational/udl.hpp
Normal file
63
sprout/rational/udl.hpp
Normal file
|
@ -0,0 +1,63 @@
|
|||
#ifndef SPROUT_RATIONAL_UDL_HPP
|
||||
#define SPROUT_RATIONAL_UDL_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/rational/rational.hpp>
|
||||
|
||||
#if SPROUT_USE_USER_DEFINED_LITERALS
|
||||
|
||||
namespace sprout {
|
||||
namespace udl {
|
||||
namespace rational {
|
||||
//
|
||||
// _r
|
||||
//
|
||||
inline SPROUT_CONSTEXPR sprout::rational<int>
|
||||
operator"" _r(unsigned long long x) {
|
||||
return sprout::rational<int>(x);
|
||||
}
|
||||
|
||||
//
|
||||
// _rl
|
||||
// _rL
|
||||
//
|
||||
inline SPROUT_CONSTEXPR sprout::rational<long>
|
||||
operator"" _rl(unsigned long long x) {
|
||||
return sprout::rational<long>(x);
|
||||
}
|
||||
inline SPROUT_CONSTEXPR sprout::rational<long>
|
||||
operator"" _rL(unsigned long long x) {
|
||||
return sprout::rational<long>(x);
|
||||
}
|
||||
|
||||
//
|
||||
// _rll
|
||||
// _rLL
|
||||
//
|
||||
inline SPROUT_CONSTEXPR sprout::rational<long long>
|
||||
operator"" _rll(unsigned long long x) {
|
||||
return sprout::rational<long long>(x);
|
||||
}
|
||||
inline SPROUT_CONSTEXPR sprout::rational<long long>
|
||||
operator"" _rLL(unsigned long long x) {
|
||||
return sprout::rational<long long>(x);
|
||||
}
|
||||
} // 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::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 sprout
|
||||
|
||||
#endif // #if SPROUT_USE_USER_DEFINED_LITERALS
|
||||
|
||||
#endif // #ifndef SPROUT_RATIONAL_UDL_HPP
|
|
@ -16,27 +16,35 @@ namespace sprout {
|
|||
// _uuid
|
||||
//
|
||||
inline SPROUT_CONSTEXPR sprout::uuids::uuid
|
||||
operator "" _uuid(char const* s, std::size_t size) {
|
||||
operator"" _uuid(char const* s, std::size_t size) {
|
||||
return sprout::uuids::string_generator()(s, s + size);
|
||||
}
|
||||
inline SPROUT_CONSTEXPR sprout::uuids::uuid
|
||||
operator "" _uuid(wchar_t const* s, std::size_t size) {
|
||||
operator"" _uuid(wchar_t const* s, std::size_t size) {
|
||||
return sprout::uuids::string_generator()(s, s + size);
|
||||
}
|
||||
inline SPROUT_CONSTEXPR sprout::uuids::uuid
|
||||
operator "" _uuid(char16_t const* s, std::size_t size) {
|
||||
operator"" _uuid(char16_t const* s, std::size_t size) {
|
||||
return sprout::uuids::string_generator()(s, s + size);
|
||||
}
|
||||
inline SPROUT_CONSTEXPR sprout::uuids::uuid
|
||||
operator "" _uuid(char32_t const* s, std::size_t size) {
|
||||
operator"" _uuid(char32_t const* s, std::size_t size) {
|
||||
return sprout::uuids::string_generator()(s, s + size);
|
||||
}
|
||||
} // namespace udl
|
||||
|
||||
using sprout::uuids::udl::operator"" _uuid;
|
||||
} // namespace uuids
|
||||
|
||||
namespace udl {
|
||||
namespace uuids {
|
||||
using sprout::uuids::udl::operator"" _uuid;
|
||||
} // namespace uuids
|
||||
|
||||
using sprout::uuids::udl::operator "" _uuid;
|
||||
using sprout::uuids::udl::operator"" _uuid;
|
||||
} // namespace udl
|
||||
|
||||
using sprout::uuids::udl::operator "" _uuid;
|
||||
using sprout::uuids::udl::operator"" _uuid;
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #if SPROUT_USE_USER_DEFINED_LITERALS
|
||||
|
|
Loading…
Reference in a new issue