fixed: add ostream operators
This commit is contained in:
parent
e3cba6b473
commit
f0021afc71
10
fixed.cpp
10
fixed.cpp
@ -191,12 +191,22 @@ LOGIC_OP(<=)
|
||||
LOGIC_OP(>)
|
||||
LOGIC_OP(>=)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// iostream operators
|
||||
template <unsigned I, unsigned E>
|
||||
std::ostream&
|
||||
util::operator<< (std::ostream &os, fixed<I,E> v)
|
||||
{
|
||||
return os << v.to_double ();
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Instantiations
|
||||
|
||||
#define INSTANTIATE(I,E) \
|
||||
template class util::fixed<(I),(E)>; \
|
||||
template std::ostream& util::operator<< (std::ostream&, fixed<(I),(E)>); \
|
||||
template bool util::operator== (util::fixed<(I),(E)>, util::fixed<(I),(E)>); \
|
||||
template bool util::operator!= (util::fixed<(I),(E)>, util::fixed<(I),(E)>); \
|
||||
template bool util::operator< (util::fixed<(I),(E)>, util::fixed<(I),(E)>); \
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "types/bits.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
|
||||
namespace util {
|
||||
template <unsigned I, unsigned E>
|
||||
@ -75,6 +76,10 @@ namespace util {
|
||||
template <unsigned I, unsigned E> bool operator<= (util::fixed<I,E>, util::fixed<I,E>);
|
||||
template <unsigned I, unsigned E> bool operator> (util::fixed<I,E>, util::fixed<I,E>);
|
||||
template <unsigned I, unsigned E> bool operator>= (util::fixed<I,E>, util::fixed<I,E>);
|
||||
|
||||
|
||||
template <unsigned I, unsigned E>
|
||||
std::ostream& operator<< (std::ostream&, fixed<I,E>);
|
||||
}
|
||||
|
||||
#endif // __UTIL_FIXED_HPP
|
||||
|
Loading…
Reference in New Issue
Block a user