yat  0.18.2pre
BinaryOstreamIterator.h
1 #ifndef _theplu_yat_utility_binary_ostream_iterator
2 #define _theplu_yat_utility_binary_ostream_iterator
3 
4 // $Id: BinaryOstreamIterator.h 3902 2020-05-05 02:17:54Z peter $
5 
6 /*
7  Copyright (C) 2020 Peter Johansson
8 
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10 
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15 
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <http://www.gnu.org/licenses/>.
23 */
24 
25 #include "utility.h"
26 
27 #include <boost/function_output_iterator.hpp>
28 
29 namespace theplu {
30 namespace yat {
31 namespace utility {
32 
33  namespace detail {
35  template <typename T>
36  class BinaryWriter
37  {
38  public:
39  BinaryWriter(std::ostream& os)
40  : out_(&os) {}
41 
42  void operator()(T x) const
43  {
44  binary_write(*out_, x);
45  }
46  private:
47  std::ostream* out_;
48  };
50  } // end detail namespace
51 
59  template <typename T>
61  : public boost::function_output_iterator<detail::BinaryWriter<T> >
62  {
63  public:
67  explicit BinaryOstreamIterator(std::ostream& os)
68  : boost::function_output_iterator<detail::BinaryWriter<T> >(detail::BinaryWriter<T>(os)) {}
69 
70  private:
71  // Using compiler generated copy
72  //BinaryOstreamIterator(const BinaryOstreamIterator&);
73  //BinaryOstreamIterator& operator=(const BinaryOstreamIterator&);
74  };
75 
76 }}} // of namespace utility, yat, and theplu
77 
78 #endif
The Department of Theoretical Physics namespace as we define it.
Some useful functions are placed here.
void binary_write(std::ostream &os, T x)
Definition: utility.h:113
BinaryOstreamIterator(std::ostream &os)
Definition: BinaryOstreamIterator.h:67
Definition: BinaryOstreamIterator.h:60

Generated on Tue Sep 7 2021 17:32:32 for yat by  doxygen 1.8.14