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

Generated on Wed Jan 25 2023 03:34:29 for yat by  doxygen 1.8.14