• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 Hans Dembinski
2 //
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt
5 // or copy at http://www.boost.org/LICENSE_1_0.txt)
6 
7 #ifndef BOOST_HISTOGRAM_TEST_UTILITY_STR_HPP
8 #define BOOST_HISTOGRAM_TEST_UTILITY_STR_HPP
9 
10 #include <sstream>
11 
12 template <class T>
str(const T & t,int w=0,bool left=true)13 auto str(const T& t, int w = 0, bool left = true) {
14   std::ostringstream os;
15   auto saved = os.width();
16   os.width(w);
17   if (left)
18     os << std::left;
19   else
20     os << std::right;
21   os << t;
22   os.width(saved);
23   return os.str();
24 }
25 
26 #endif
27