rippled
Loading...
Searching...
No Matches
include/xrpl/beast/unit_test/amount.h
1// Distributed under the Boost Software License, Version 1.0. (See accompanying
2// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
3//
4
5#pragma once
6
7#include <cstddef>
8#include <ostream>
9#include <string>
10
11namespace beast {
12namespace unit_test {
13
15class amount
16{
17private:
20
21public:
22 amount(amount const&) = default;
23 amount&
24 operator=(amount const&) = delete;
25
26 template <class = void>
27 amount(std::size_t n, std::string const& what);
28
29 friend std::ostream&
30 operator<<(std::ostream& s, amount const& t);
31};
32
33template <class>
34amount::amount(std::size_t n, std::string const& what) : n_(n), what_(what)
35{
36}
37
39operator<<(std::ostream& s, amount const& t)
40{
41 s << t.n_ << " " << t.what_ << ((t.n_ != 1) ? "s" : "");
42 return s;
43}
44
45} // namespace unit_test
46} // namespace beast
Utility for producing nicely composed output of amounts with units.
friend std::ostream & operator<<(std::ostream &s, amount const &t)
amount & operator=(amount const &)=delete
amount(amount const &)=default
std::ostream & operator<<(std::ostream &s, amount const &t)