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 << "["; os << "[";
std::transform (std::cbegin (b), std::transform (std::cbegin (b),
std::cend (b), std::cend (b),
infix_iterator<stream::numeric<value_type>> (os, ", "), infix_iterator<value_type> (os, ", "),
stream::to_numeric<value_type>); [] (auto i) { return +i; });
os << "]"; os << "]";
return os; return os;

View File

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

View File

@ -18,37 +18,9 @@
#define __UTIL_STREAM_HPP #define __UTIL_STREAM_HPP
#include <iostream> #include <iostream>
#include "types/bits.hpp"
namespace util { namespace util {
namespace stream { 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> { class null_streambuf : public std::basic_streambuf<char> {
public: public: