Commit 8ca84b10 authored by Manuel Günther's avatar Manuel Günther
Browse files

Added vector IO functions from boost

parent 9b0ded25
......@@ -22,7 +22,6 @@
#include <boost/random/uniform_01.hpp>
#include <boost/random/uniform_int.hpp>
#include <boost/random/detail/config.hpp>
#include <boost/random/detail/vector_io.hpp>
#include <bob.core/boost/operators.hpp>
......
......@@ -81,4 +81,62 @@
{ return !(lhs == rhs); }
#endif
// from vector_io.hpp
namespace boost {
namespace random {
namespace detail {
template<class CharT, class Traits, class T>
void print_vector(std::basic_ostream<CharT, Traits>& os,
const std::vector<T>& vec)
{
typename std::vector<T>::const_iterator
iter = vec.begin(),
end = vec.end();
os << os.widen('[');
if(iter != end) {
os << *iter;
++iter;
for(; iter != end; ++iter)
{
os << os.widen(' ') << *iter;
}
}
os << os.widen(']');
}
template<class CharT, class Traits, class T>
void read_vector(std::basic_istream<CharT, Traits>& is, std::vector<T>& vec)
{
CharT ch;
if(!(is >> ch)) {
return;
}
if(ch != is.widen('[')) {
is.putback(ch);
is.setstate(std::ios_base::failbit);
return;
}
T val;
while(is >> std::ws >> val) {
vec.push_back(val);
}
if(is.fail()) {
is.clear();
if(!(is >> ch)) {
return;
}
if(ch != is.widen(']')) {
is.putback(ch);
is.setstate(std::ios_base::failbit);
}
}
}
}
}
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment