https://mooseframework.inl.gov
Loading...
Searching...
No Matches
InfixIterator.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#pragma once
11
12// infix_iterator.h
13
14// Lifted from Jerry Coffin's 's prefix_ostream_iterator, no copyright or license
15
16#include <ostream>
17#include <iterator>
18
19template <class T, class charT = char, class traits = std::char_traits<charT>>
26#if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ <= 9)
27 : public std::iterator<std::output_iterator_tag, void, void, void, void>
28#endif
29{
30#if defined(__clang__) || (__GNUC__ > 9)
31 using iterator_category = std::output_iterator_tag;
32#endif
33
34 std::basic_ostream<charT, traits> * os;
35 charT const * delimiter;
37
38public:
39 typedef charT char_type;
40 typedef traits traits_type;
41 typedef std::basic_ostream<charT, traits> ostream_type;
43 infix_ostream_iterator(ostream_type & s, charT const * d, bool first = true)
44 : os(&s), delimiter(d), first_elem(first)
45 {
46 }
48 {
49 // Here's the only real change from ostream_iterator:
50 // Normally, the '*os << item;' would come before the 'if'.
51 if (!first_elem && delimiter != 0)
52 *os << delimiter;
53 *os << item;
54 first_elem = false;
55 return *this;
56 }
60};
if(!dmm->_nl) SETERRQ(PETSC_COMM_WORLD
GCC9 currently hits a "no type named 'value_type'" error during build if this is removed and iterator...
charT const * delimiter
infix_ostream_iterator(ostream_type &s)
std::output_iterator_tag iterator_category
std::basic_ostream< charT, traits > * os
infix_ostream_iterator< T, charT, traits > & operator=(T const &item)
std::basic_ostream< charT, traits > ostream_type
infix_ostream_iterator< T, charT, traits > & operator++()
infix_ostream_iterator< T, charT, traits > & operator++(int)
infix_ostream_iterator(ostream_type &s, charT const *d, bool first=true)
infix_ostream_iterator< T, charT, traits > & operator*()