1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-11-12 21:09:01 +00:00

fix explicit conversion: optional::operator bool, string::operator std::string, string_ref::operator std::string

This commit is contained in:
bolero-MURAKAMI 2013-05-28 12:36:36 +09:00
parent e5efbfe340
commit 7f6081e0cc
5 changed files with 15 additions and 16 deletions

View file

@ -219,16 +219,16 @@ namespace sprout {
inline SPROUT_CONSTEXPR sprout::complex<T> log10(sprout::complex<T> const& x) {
return sprout::log(x) / sprout::log(T(10));
}
//
// pow
//
namespace detail {
template<typename T>
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());
}
} // namespace detail
//
// pow
//
template<typename T>
inline SPROUT_CONSTEXPR sprout::complex<T>
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);
}
} // namespace detail
//
// tan
// tanh
//
template<typename T>
inline SPROUT_CONSTEXPR sprout::complex<T>
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()))))
;
}
//
// tan
// tanh
//
template<typename T>
inline SPROUT_CONSTEXPR sprout::complex<T>
tan(sprout::complex<T> const& x) {

View file

@ -47,11 +47,14 @@
//
// SPROUT_USE_EXPLICIT_CONVERSION_OPERATORS
// SPROUT_EXPLICIT_CONVERSION
//
#ifndef SPROUT_CONFIG_DISABLE_EXPLICIT_CONVERSION_OPERATORS
# define SPROUT_USE_EXPLICIT_CONVERSION_OPERATORS 1
# define SPROUT_EXPLICIT_CONVERSION explicit
#else // #ifndef SPROUT_CONFIG_DISABLE_EXPLICIT_CONVERSION_OPERATORS
# define SPROUT_USE_EXPLICIT_CONVERSION_OPERATORS 0
# define SPROUT_EXPLICIT_CONVERSION
#endif // #ifndef SPROUT_CONFIG_DISABLE_EXPLICIT_CONVERSION_OPERATORS
//

View file

@ -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();
}
SPROUT_CONSTEXPR bool operator!() const SPROUT_NOEXCEPT {

View file

@ -493,12 +493,10 @@ namespace sprout {
sprout::make_index_tuple<N2>::make()
);
}
#if SPROUT_USE_EXPLICIT_CONVERSION_OPERATORS
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());
}
#endif
pointer
c_array() SPROUT_NOEXCEPT {
return &elems[0];

View file

@ -390,12 +390,10 @@ namespace sprout {
return size() >= str.size() && traits_type::compare(data() + size() - str.size(), str.data(), str.size()) == 0;
}
// others:
#if SPROUT_USE_EXPLICIT_CONVERSION_OPERATORS
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());
}
#endif
pointer
c_array() SPROUT_NOEXCEPT {
return data();