]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/beast/subtree/unit_test/include/boost/beast/unit_test/amount.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / beast / subtree / unit_test / include / boost / beast / unit_test / amount.hpp
1 //
2 // Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // Official repository: https://github.com/boostorg/beast
8 //
9
10 #ifndef BOOST_BEAST_UNIT_TEST_AMOUNT_HPP
11 #define BOOST_BEAST_UNIT_TEST_AMOUNT_HPP
12
13 #include <cstddef>
14 #include <ostream>
15 #include <string>
16
17 namespace boost {
18 namespace beast {
19 namespace unit_test {
20
21 /** Utility for producing nicely composed output of amounts with units. */
22 class amount
23 {
24 private:
25 std::size_t n_;
26 std::string const& what_;
27
28 public:
29 amount(amount const&) = default;
30 amount& operator=(amount const&) = delete;
31
32 template<class = void>
33 amount(std::size_t n, std::string const& what);
34
35 friend
36 std::ostream&
37 operator<<(std::ostream& s, amount const& t);
38 };
39
40 template<class>
41 amount::amount(std::size_t n, std::string const& what)
42 : n_(n)
43 , what_(what)
44 {
45 }
46
47 inline
48 std::ostream&
49 operator<<(std::ostream& s, amount const& t)
50 {
51 s << t.n_ << " " << t.what_ <<((t.n_ != 1) ? "s" : "");
52 return s;
53 }
54
55 } // unit_test
56 } // beast
57 } // boost
58
59 #endif