#include "Memory"
#include <iostream>
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(_WIN32) && defined(_GLIBCXX_OSTREAM)
+#define VC_HACK_OSTREAM_FOR_TTY 1
+#endif
+
+#ifdef VC_HACK_OSTREAM_FOR_TTY
#include <unistd.h>
#include <ext/stdio_sync_filebuf.h>
#endif
static const Type normal = { "\033[0m" };
} // namespace AnsiColor
-#ifdef __GNUC__
+#ifdef VC_HACK_OSTREAM_FOR_TTY
class hacked_ostream : public std::ostream
{
public:
using std::ostream::_M_streambuf;
};
- static bool mayUseColor(const std::ostream &os)
- __attribute__((__const__));
- static bool mayUseColor(const std::ostream &os)
+ __attribute__((__const__)) bool mayUseColor(const std::ostream &os)
{
std::basic_streambuf<char> *hack1 = const_cast<std::basic_streambuf<char> *>(os.*(&hacked_ostream::_M_streambuf));
__gnu_cxx::stdio_sync_filebuf<char> *hack = dynamic_cast<__gnu_cxx::stdio_sync_filebuf<char> *>(hack1);
return 1 == isatty(fileno(file));
}
#else
- static bool mayUseColor(const std::ostream &) { return false; }
+ inline bool mayUseColor(const std::ostream &) { return false; }
#endif
} // anonymous namespace
namespace std
{
-static inline std::ostream &operator<<(std::ostream &out, const AnsiColor::Type &c)
+inline std::ostream &operator<<(std::ostream &out, const AnsiColor::Type &c)
{
if (mayUseColor(out)) {
out << c.data;
}
template<typename T>
-static std::ostream &operator<<(std::ostream &out, const VECTOR_NAMESPACE::Vector<T> &v)
+inline std::ostream &operator<<(std::ostream &out, const VECTOR_NAMESPACE::Vector<T> &v)
{
out << AnsiColor::green << "[";
out << v[0];
return out;
}
-static std::ostream &operator<<(std::ostream &out, const VECTOR_NAMESPACE::Vector<char> &v)
+inline std::ostream &operator<<(std::ostream &out, const VECTOR_NAMESPACE::Vector<char> &v)
{
out << AnsiColor::green << "[";
out << int(v[0]);
out << "]" << AnsiColor::normal;
return out;
}
-static std::ostream &operator<<(std::ostream &out, const VECTOR_NAMESPACE::Vector<unsigned char> &v)
+inline std::ostream &operator<<(std::ostream &out, const VECTOR_NAMESPACE::Vector<unsigned char> &v)
{
out << AnsiColor::green << "[";
out << int(v[0]);
#ifdef VC_HAVE_FMA
template<typename T>
-static std::ostream &operator<<(std::ostream &out, const VECTOR_NAMESPACE::VectorMultiplication<T> &v)
+inline std::ostream &operator<<(std::ostream &out, const VECTOR_NAMESPACE::VectorMultiplication<T> &v)
{
return out << VECTOR_NAMESPACE::Vector<T>(v);
}
#ifdef VC_IMPL_AVX
template<unsigned int VectorSize, size_t RegisterWidth>
-static std::ostream &operator<<(std::ostream &out, const VECTOR_NAMESPACE::Mask<VectorSize, RegisterWidth> &m)
+inline std::ostream &operator<<(std::ostream &out, const VECTOR_NAMESPACE::Mask<VectorSize, RegisterWidth> &m)
#else
template<unsigned int VectorSize>
-static std::ostream &operator<<(std::ostream &out, const VECTOR_NAMESPACE::Mask<VectorSize> &m)
+inline std::ostream &operator<<(std::ostream &out, const VECTOR_NAMESPACE::Mask<VectorSize> &m)
#endif
{
out << AnsiColor::blue << "m[";
out << AnsiColor::blue << "]" << AnsiColor::normal;
return out;
}
-#if VC_IMPL_SSE
-static std::ostream &operator<<(std::ostream &out, const VECTOR_NAMESPACE::Float8Mask &m)
+#ifdef VC_IMPL_SSE
+inline std::ostream &operator<<(std::ostream &out, const VECTOR_NAMESPACE::Float8Mask &m)
{
out << AnsiColor::blue << "m[";
for (unsigned int i = 0; i < 8; ++i) {
#endif
template<typename V, typename Parent, typename RM>
-static std::ostream &operator<<(std::ostream &out, const Vc::MemoryBase<V, Parent, 1, RM> &m )
+inline std::ostream &operator<<(std::ostream &out, const Vc::MemoryBase<V, Parent, 1, RM> &m )
{
out << AnsiColor::blue << "{" << AnsiColor::normal;
for (unsigned int i = 0; i < m.vectorsCount(); ++i) {
}
template<typename V, typename Parent, typename RM>
-static std::ostream &operator<<(std::ostream &out, const Vc::MemoryBase<V, Parent, 2, RM> &m )
+inline std::ostream &operator<<(std::ostream &out, const Vc::MemoryBase<V, Parent, 2, RM> &m )
{
out << AnsiColor::blue << "{" << AnsiColor::normal;
for (size_t i = 0; i < m.rowsCount(); ++i) {