Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
valarray.h
Go to the documentation of this file.
1
30#ifndef VALARRAY_H_INCLUDED
31#define VALARRAY_H_INCLUDED
32
33
34#include <valarray>
35#include <ostream>
36
37#include <examples.h>
38
39template<class T>
40inline std::ostream&
41insert_valarray (std::ostream &out, const std::valarray<T> &v)
42{
43 out << "[";
44 for (std::size_t i = 0; i < v.size (); i++) {
45 out << v [i];
46 if (i < v.size () - 1)
47 out << ",";
48 }
49 return out << "]";
50}
51
52// Non-templatized insertion operators necessary for implicit
53// conversion from slice_array<T> (etc.) to valarray<T>. (the
54// conversion won't work in template argument deduction).
55inline std::ostream& operator<< (std::ostream &out, const std::valarray<int> &v)
56{
57 return insert_valarray (out, v);
58}
59
60std::ostream& operator<< (std::ostream &out, const std::valarray<bool> &v)
61{
62 return insert_valarray (out, v);
63}
64
65#endif // VALARRAY_H_INCLUDED
#define i
Definition 17.names.cpp:126
#define v
Definition 17.names.cpp:138
const int out
std::ostream & operator<<(std::ostream &out, const std::valarray< int > &v)
Definition valarray.h:55
std::ostream & insert_valarray(std::ostream &out, const std::valarray< T > &v)
Definition valarray.h:41