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

fix value_holder i/o

This commit is contained in:
bolero-MURAKAMI 2018-05-19 18:53:36 +09:00
parent 44f16918b7
commit 582e50e4a7

View file

@ -10,6 +10,7 @@
#include <istream>
#include <ostream>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/utility/value_holder/value_holder.hpp>
@ -18,7 +19,10 @@ namespace sprout {
// operator>>
//
template<typename Elem, typename Traits, typename T>
inline SPROUT_NON_CONSTEXPR std::basic_istream<Elem, Traits>&
inline SPROUT_NON_CONSTEXPR typename std::enable_if<
!std::is_reference<T>::value,
std::basic_istream<Elem, Traits>&
>::type
operator>>(std::basic_istream<Elem, Traits>& lhs, sprout::value_holder<T>& rhs) {
if (lhs.good()) {
int d = lhs.get();
@ -32,28 +36,6 @@ namespace sprout {
}
return lhs;
}
template<typename Elem, typename Traits, typename T>
inline SPROUT_NON_CONSTEXPR std::basic_istream<Elem, Traits>&
operator>>(std::basic_istream<Elem, Traits>& lhs, sprout::value_holder<T&>& rhs) {
if (lhs.good()) {
int d = lhs.get();
if (d == ' ') {
T x;
lhs >> x;
rhs = x;
} else {
if (d == '-') {
d = lhs.get();
if (d == '-') {
rhs = sprout::value_holder<T&>();
return lhs;
}
}
lhs.setstate(std::ios::failbit);
}
}
return lhs;
}
//
// operator<<
//