1 // Copyright 2015-2017 Hans Dembinski
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)
7 #ifndef BOOST_HISTOGRAM_LITERALS_HPP
8 #define BOOST_HISTOGRAM_LITERALS_HPP
10 #include <type_traits>
15 constexpr unsigned parse_number(unsigned n) { return n; }
17 template <class... Rest>
18 constexpr unsigned parse_number(unsigned n, char f, Rest... rest) {
19 return parse_number(10u * n + static_cast<unsigned>(f - '0'), rest...);
24 /// Suffix operator to generate literal compile-time numbers, 0_c, 12_c, etc.
25 template <char... digits>
26 auto operator"" _c() {
27 return std::integral_constant<unsigned, detail::parse_number(0, digits...)>();
29 } // namespace literals
30 } // namespace histogram