]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/units/include/boost/units/detail/utility.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / units / include / boost / units / detail / utility.hpp
1 // Boost.Units - A C++ library for zero-overhead dimensional analysis and
2 // unit/quantity manipulation and conversion
3 //
4 // Copyright (C) 2003-2008 Matthias Christian Schabel
5 // Copyright (C) 2008 Steven Watanabe
6 //
7 // Distributed under the Boost Software License, Version 1.0. (See
8 // accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10
11 #ifndef BOOST_UNITS_UTILITY_HPP
12 #define BOOST_UNITS_UTILITY_HPP
13
14 #include <typeinfo>
15 #include <string>
16 #include <boost/core/demangle.hpp>
17
18 namespace boost {
19
20 namespace units {
21
22 namespace detail {
23
24 inline
25 std::string
26 demangle(const char* name)
27 {
28 std::string demangled = core::demangle(name);
29
30 const std::string::size_type prefix_len = sizeof("boost::units::") - 1;
31 std::string::size_type i = 0;
32 for (;;)
33 {
34 std::string::size_type pos = demangled.find("boost::units::", i, prefix_len);
35 if (pos == std::string::npos)
36 break;
37
38 demangled.erase(pos, prefix_len);
39 i = pos;
40 }
41
42 return demangled;
43 }
44
45 } // namespace detail
46
47 template<class L>
48 inline std::string simplify_typename(const L& /*source*/)
49 {
50 return detail::demangle(typeid(L).name());
51 }
52
53 } // namespace units
54
55 } // namespace boost
56
57 #endif // BOOST_UNITS_UTILITY_HPP