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 template<typename _CharT, typename _Traits>
31 class basic_nullstream : virtual public std::basic_ostream<_CharT, _Traits> {
32 public:
33  explicit basic_nullstream() : std::basic_ostream<_CharT, _Traits>(NULL) {}
34 };
35 
37 
38 inline
39 Ptr<std::ostream> makeStreamPtr( std::ostream& os, bool noSuppressOutput=true ) {
40  Ptr<std::ostream> retstream;
41  if( noSuppressOutput ) retstream = makePtrFromRef<std::ostream>(os);
42  else retstream = makePtr<nullstream>();
43  return retstream; // noSuppressOutput ? makePtrFromRef( os ) : makePtr<nullstream>();
44 }
45 
46 inline
47 Ptr<std::ostream> makeStreamPtr( Ptr<std::ostream> os, bool noSuppressOutput=true ) {
48  Ptr<std::ostream> retstream;
49  if( noSuppressOutput ) retstream = os;
50  else retstream = makePtr<nullstream>();
51  return retstream; // noSuppressOutput ? makePtrFromRef( os ) : makePtr<nullstream>();
52 // return noSuppressOutput ? os : makePtr<nullstream>();
53 }
54 
55 } // details
56 
59 
60 } // namespace ROL
61 
62 
63 #endif
Ptr< std::ostream > makeStreamPtr(std::ostream &os, bool noSuppressOutput=true)
Definition: ROL_Stream.hpp:39
basic_nullstream< char, std::char_traits< char >> nullstream
Definition: ROL_Stream.hpp:36