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
26namespace ROL {
27
28namespace details {
29
30template<typename _CharT, typename _Traits>
31class basic_nullstream : virtual public std::basic_ostream<_CharT, _Traits> {
32public:
33 explicit basic_nullstream() : std::basic_ostream<_CharT, _Traits>(NULL) {}
34};
35
37
38inline
39Ptr<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
46inline
47Ptr<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
58using details::makeStreamPtr;
59
60} // namespace ROL
61
62
63#endif
Ptr< std::ostream > makeStreamPtr(std::ostream &os, bool noSuppressOutput=true)
basic_nullstream< char, std::char_traits< char > > nullstream