stream: remove unneeded numeric class

explicitly cast before passing to a stream routine if you need it.
This commit is contained in:
Danny Robson 2016-06-29 17:52:26 +10:00
parent b1bc2a816d
commit d51cfe7a34
3 changed files with 4 additions and 35 deletions

View File

@ -440,8 +440,8 @@ util::operator<< (std::ostream &os, const bezier<S> &b)
os << "[";
std::transform (std::cbegin (b),
std::cend (b),
infix_iterator<stream::numeric<value_type>> (os, ", "),
stream::to_numeric<value_type>);
infix_iterator<value_type> (os, ", "),
[] (auto i) { return +i; });
os << "]";
return os;

View File

@ -18,7 +18,6 @@
#define __UTIL_IOSTREAM
#include "../iterator.hpp"
#include "../stream.hpp"
#include <ostream>
#include <algorithm>
@ -35,10 +34,8 @@ namespace util {
os << "[";
std::transform (std::cbegin (k),
std::cend (k),
infix_iterator<
stream::numeric<T>
> (os, ", "),
stream::to_numeric<T>);
infix_iterator<T> (os, ", "),
[] (auto i) { return +i; });
os << "]";
return os;

View File

@ -18,37 +18,9 @@
#define __UTIL_STREAM_HPP
#include <iostream>
#include "types/bits.hpp"
namespace util {
namespace stream {
///////////////////////////////////////////////////////////////////////
template <typename T>
struct numeric
{
explicit numeric (T _val): val (_val) { ; }
T val;
};
//---------------------------------------------------------------------
template <typename T>
numeric<T>
to_numeric (const T &t)
{
return numeric<T> (t);
}
//---------------------------------------------------------------------
template <typename T>
std::ostream&
operator<< (std::ostream &os, numeric<T> n)
{
return os << +n.val;
}
///////////////////////////////////////////////////////////////////////
class null_streambuf : public std::basic_streambuf<char> {
public: