mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +00:00
fix explicit conversion: optional::operator bool, string::operator std::string, string_ref::operator std::string
This commit is contained in:
parent
e5efbfe340
commit
7f6081e0cc
5 changed files with 15 additions and 16 deletions
|
@ -219,16 +219,16 @@ namespace sprout {
|
||||||
inline SPROUT_CONSTEXPR sprout::complex<T> log10(sprout::complex<T> const& x) {
|
inline SPROUT_CONSTEXPR sprout::complex<T> log10(sprout::complex<T> const& x) {
|
||||||
return sprout::log(x) / sprout::log(T(10));
|
return sprout::log(x) / sprout::log(T(10));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// pow
|
||||||
|
//
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline SPROUT_CONSTEXPR sprout::complex<T> pow_impl(sprout::complex<T> const& t, T const& y) {
|
inline SPROUT_CONSTEXPR sprout::complex<T> pow_impl(sprout::complex<T> const& t, T const& y) {
|
||||||
return sprout::polar(sprout::exp(y * t.real()), y * t.imag());
|
return sprout::polar(sprout::exp(y * t.real()), y * t.imag());
|
||||||
}
|
}
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
//
|
|
||||||
// pow
|
|
||||||
//
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline SPROUT_CONSTEXPR sprout::complex<T>
|
inline SPROUT_CONSTEXPR sprout::complex<T>
|
||||||
pow(sprout::complex<T> const& x, T const& y) {
|
pow(sprout::complex<T> const& x, T const& y) {
|
||||||
|
@ -295,11 +295,6 @@ namespace sprout {
|
||||||
return sprout::detail::sqrt_impl_2_1(x, t, t / 2);
|
return sprout::detail::sqrt_impl_2_1(x, t, t / 2);
|
||||||
}
|
}
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
//
|
|
||||||
// tan
|
|
||||||
// tanh
|
|
||||||
//
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline SPROUT_CONSTEXPR sprout::complex<T>
|
inline SPROUT_CONSTEXPR sprout::complex<T>
|
||||||
sqrt(sprout::complex<T> const& x) {
|
sqrt(sprout::complex<T> const& x) {
|
||||||
|
@ -307,6 +302,11 @@ namespace sprout {
|
||||||
: sprout::detail::sqrt_impl_2(x, sprout::sqrt(2 * (sprout::abs(x) + sprout::abs(x.real()))))
|
: sprout::detail::sqrt_impl_2(x, sprout::sqrt(2 * (sprout::abs(x) + sprout::abs(x.real()))))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// tan
|
||||||
|
// tanh
|
||||||
|
//
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline SPROUT_CONSTEXPR sprout::complex<T>
|
inline SPROUT_CONSTEXPR sprout::complex<T>
|
||||||
tan(sprout::complex<T> const& x) {
|
tan(sprout::complex<T> const& x) {
|
||||||
|
|
|
@ -47,11 +47,14 @@
|
||||||
|
|
||||||
//
|
//
|
||||||
// SPROUT_USE_EXPLICIT_CONVERSION_OPERATORS
|
// SPROUT_USE_EXPLICIT_CONVERSION_OPERATORS
|
||||||
|
// SPROUT_EXPLICIT_CONVERSION
|
||||||
//
|
//
|
||||||
#ifndef SPROUT_CONFIG_DISABLE_EXPLICIT_CONVERSION_OPERATORS
|
#ifndef SPROUT_CONFIG_DISABLE_EXPLICIT_CONVERSION_OPERATORS
|
||||||
# define SPROUT_USE_EXPLICIT_CONVERSION_OPERATORS 1
|
# define SPROUT_USE_EXPLICIT_CONVERSION_OPERATORS 1
|
||||||
|
# define SPROUT_EXPLICIT_CONVERSION explicit
|
||||||
#else // #ifndef SPROUT_CONFIG_DISABLE_EXPLICIT_CONVERSION_OPERATORS
|
#else // #ifndef SPROUT_CONFIG_DISABLE_EXPLICIT_CONVERSION_OPERATORS
|
||||||
# define SPROUT_USE_EXPLICIT_CONVERSION_OPERATORS 0
|
# define SPROUT_USE_EXPLICIT_CONVERSION_OPERATORS 0
|
||||||
|
# define SPROUT_EXPLICIT_CONVERSION
|
||||||
#endif // #ifndef SPROUT_CONFIG_DISABLE_EXPLICIT_CONVERSION_OPERATORS
|
#endif // #ifndef SPROUT_CONFIG_DISABLE_EXPLICIT_CONVERSION_OPERATORS
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -294,7 +294,7 @@ namespace sprout {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
SPROUT_CONSTEXPR operator bool() const SPROUT_NOEXCEPT {
|
SPROUT_EXPLICIT_CONVERSION SPROUT_CONSTEXPR operator bool() const SPROUT_NOEXCEPT {
|
||||||
return is_initialized();
|
return is_initialized();
|
||||||
}
|
}
|
||||||
SPROUT_CONSTEXPR bool operator!() const SPROUT_NOEXCEPT {
|
SPROUT_CONSTEXPR bool operator!() const SPROUT_NOEXCEPT {
|
||||||
|
|
|
@ -493,12 +493,10 @@ namespace sprout {
|
||||||
sprout::make_index_tuple<N2>::make()
|
sprout::make_index_tuple<N2>::make()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
#if SPROUT_USE_EXPLICIT_CONVERSION_OPERATORS
|
|
||||||
template<typename Allocator>
|
template<typename Allocator>
|
||||||
explicit operator std::basic_string<T, Traits, Allocator>() const {
|
SPROUT_EXPLICIT_CONVERSION operator std::basic_string<T, Traits, Allocator>() const {
|
||||||
return std::basic_string<T, Traits, Allocator>(data(), size());
|
return std::basic_string<T, Traits, Allocator>(data(), size());
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
pointer
|
pointer
|
||||||
c_array() SPROUT_NOEXCEPT {
|
c_array() SPROUT_NOEXCEPT {
|
||||||
return &elems[0];
|
return &elems[0];
|
||||||
|
|
|
@ -390,12 +390,10 @@ namespace sprout {
|
||||||
return size() >= str.size() && traits_type::compare(data() + size() - str.size(), str.data(), str.size()) == 0;
|
return size() >= str.size() && traits_type::compare(data() + size() - str.size(), str.data(), str.size()) == 0;
|
||||||
}
|
}
|
||||||
// others:
|
// others:
|
||||||
#if SPROUT_USE_EXPLICIT_CONVERSION_OPERATORS
|
|
||||||
template<typename Allocator>
|
template<typename Allocator>
|
||||||
explicit operator std::basic_string<T, Traits, Allocator>() const {
|
SPROUT_EXPLICIT_CONVERSION operator std::basic_string<T, Traits, Allocator>() const {
|
||||||
return std::basic_string<T, Traits, Allocator>(data(), size());
|
return std::basic_string<T, Traits, Allocator>(data(), size());
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
pointer
|
pointer
|
||||||
c_array() SPROUT_NOEXCEPT {
|
c_array() SPROUT_NOEXCEPT {
|
||||||
return data();
|
return data();
|
||||||
|
|
Loading…
Reference in a new issue