Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:25:00

0001 //
0002 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // Official repository: https://github.com/boostorg/beast
0008 //
0009 
0010 #ifndef BOOST_BEAST_UNIT_TEST_AMOUNT_HPP
0011 #define BOOST_BEAST_UNIT_TEST_AMOUNT_HPP
0012 
0013 #include <cstddef>
0014 #include <ostream>
0015 #include <string>
0016 
0017 namespace boost {
0018 namespace beast {
0019 namespace unit_test {
0020 
0021 /** Utility for producing nicely composed output of amounts with units. */
0022 class amount
0023 {
0024 private:
0025     std::size_t n_;
0026     std::string const& what_;
0027 
0028 public:
0029     amount(amount const&) = default;
0030     amount& operator=(amount const&) = delete;
0031 
0032     template<class = void>
0033     amount(std::size_t n, std::string const& what);
0034 
0035     friend
0036     std::ostream&
0037     operator<<(std::ostream& s, amount const& t);
0038 };
0039 
0040 template<class>
0041 amount::amount(std::size_t n, std::string const& what)
0042     : n_(n)
0043     , what_(what)
0044 {
0045 }
0046 
0047 inline
0048 std::ostream&
0049 operator<<(std::ostream& s, amount const& t)
0050 {
0051     s << t.n_ << " " << t.what_ <<((t.n_ != 1) ? "s" : "");
0052     return s;
0053 }
0054 
0055 } // unit_test
0056 } // beast
0057 } // boost
0058 
0059 #endif