annotate DEPENDENCIES/generic/include/boost/chrono/io/utility/manip_base.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // boost/chrono/utility/manip_base.hpp ------------------------------------------------------------//
Chris@16 2
Chris@16 3 // Copyright 2011 Vicente J. Botet Escriba
Chris@16 4
Chris@16 5 // Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 6 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 7
Chris@16 8 // See http://www.boost.org/libs/chrono for documentation.
Chris@16 9
Chris@16 10 #ifndef BOOST_CHRONO_UTILITY_MANIP_BASE_PTR_HPP
Chris@16 11 #define BOOST_CHRONO_UTILITY_MANIP_BASE_PTR_HPP
Chris@16 12
Chris@16 13 #include <ios>
Chris@16 14
Chris@16 15 /**
Chris@16 16 *
Chris@16 17
Chris@16 18 */
Chris@16 19
Chris@16 20 namespace boost
Chris@16 21 {
Chris@16 22 namespace chrono
Chris@16 23 {
Chris@16 24
Chris@16 25 /**
Chris@16 26 * manip is a manipulator mixin class following the CRTP.
Chris@16 27 * @tparam Final the derived from manip and final type
Chris@16 28 *
Chris@16 29 * @Example
Chris@16 30 * @code
Chris@16 31
Chris@16 32 class mendl: public manip<mendl>
Chris@16 33 {
Chris@16 34 public:
Chris@16 35 explicit mendl(size_t how_many) :
Chris@16 36 count(how_many) {}
Chris@16 37 template <typename out_stream>
Chris@16 38 void operator()(out_stream &out) const
Chris@16 39 {
Chris@16 40 for (size_t line = 0; line < count; ++line)
Chris@16 41 {
Chris@16 42 out.put(out.widen('\n'));
Chris@16 43 }
Chris@16 44 out.flush();
Chris@16 45 }
Chris@16 46 private:
Chris@16 47 size_t count;
Chris@16 48 };
Chris@16 49
Chris@16 50 * @codeend
Chris@16 51 */
Chris@16 52 template <typename Final>
Chris@16 53 class manip
Chris@16 54 {
Chris@16 55 public:
Chris@16 56 /**
Chris@16 57 *
Chris@16 58 * @param ios the io stream or ios_base.
Chris@16 59 * @Effects calls to the manipulator final functor.
Chris@16 60 */
Chris@16 61 //template <typename out_stream>
Chris@16 62 void operator()(std::ios_base &ios) const
Chris@16 63 {
Chris@16 64 (*static_cast<const Final *> (this))(ios);
Chris@16 65 }
Chris@16 66 };
Chris@16 67
Chris@16 68 /**
Chris@16 69 * @c manip stream inserter
Chris@16 70 * @param out the io stream or ios_base.
Chris@16 71 * @param op the manipulator instance.
Chris@16 72 * @Effects if @c out is good calls to the manipulator functor @op.
Chris@16 73 * @return @c out
Chris@16 74 */
Chris@16 75 template <typename out_stream, typename manip_type>
Chris@16 76 out_stream &operator<<(out_stream &out, const manip<manip_type> &op)
Chris@16 77 {
Chris@16 78 if (out.good())
Chris@16 79 op(out);
Chris@16 80 return out;
Chris@16 81 }
Chris@16 82
Chris@16 83 /**
Chris@16 84 * @c manip stream extractor
Chris@16 85 * @param in the io stream or ios_base.
Chris@16 86 * @param op the manipulator instance.
Chris@16 87 * @Effects if @c in is good calls to the manipulator functor @op.
Chris@16 88 * @return @c in
Chris@16 89 */
Chris@16 90 template <typename in_stream, typename manip_type>
Chris@16 91 in_stream &operator>>(in_stream &in, const manip<manip_type> &op)
Chris@16 92 {
Chris@16 93 if (in.good())
Chris@16 94 op(in);
Chris@16 95 return in;
Chris@16 96 }
Chris@16 97
Chris@16 98 } // namespace chrono
Chris@16 99 } // namespace boost
Chris@16 100
Chris@16 101 #endif // header