ROL
ROL_Stream.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Rapid Optimization Library (ROL) Package
4 //
5 // Copyright 2014 NTESS and the ROL contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #pragma once
11 #ifndef ROL_STREAM_HPP
12 #define ROL_STREAM_HPP
13 
14 #include <ostream>
15 #include <string>
16 #include "ROL_Ptr.hpp"
17 
26 namespace ROL {
27 
28 namespace details {
29 
30 using namespace std;
31 
32 template<typename _CharT, typename _Traits>
33 class basic_nullstream : virtual public basic_ostream<_CharT, _Traits> {
34 public:
35  explicit basic_nullstream() : basic_ostream<_CharT, _Traits>(NULL) {}
36 };
37 
39 
40 inline
41 Ptr<ostream> makeStreamPtr( ostream& os, bool noSuppressOutput=true ) {
42  Ptr<ostream> retstream;
43  if( noSuppressOutput ) retstream = makePtrFromRef<ostream>(os);
44  else retstream = makePtr<nullstream>();
45  return retstream; // noSuppressOutput ? makePtrFromRef( os ) : makePtr<nullstream>();
46 }
47 
48 inline
49 Ptr<ostream> makeStreamPtr( Ptr<ostream> os, bool noSuppressOutput=true ) {
50  Ptr<ostream> retstream;
51  if( noSuppressOutput ) retstream = os;
52  else retstream = makePtr<nullstream>();
53  return retstream; // noSuppressOutput ? makePtrFromRef( os ) : makePtr<nullstream>();
54 // return noSuppressOutput ? os : makePtr<nullstream>();
55 }
56 
57 } // details
58 
61 
62 } // namespace ROL
63 
64 
65 #endif
Ptr< ostream > makeStreamPtr(ostream &os, bool noSuppressOutput=true)
Definition: ROL_Stream.hpp:41
basic_nullstream< char, char_traits< char >> nullstream
Definition: ROL_Stream.hpp:38