Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:53:11

0001 // Copyright 2015-2017 Hans Dembinski
0002 //
0003 // Distributed under the Boost Software License, Version 1.0.
0004 // (See accompanying file LICENSE_1_0.txt
0005 // or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 #ifndef BOOST_HISTOGRAM_LITERALS_HPP
0008 #define BOOST_HISTOGRAM_LITERALS_HPP
0009 
0010 #include <type_traits>
0011 
0012 namespace boost {
0013 namespace histogram {
0014 namespace detail {
0015 constexpr unsigned parse_number(unsigned n) { return n; }
0016 
0017 template <class... Rest>
0018 constexpr unsigned parse_number(unsigned n, char f, Rest... rest) {
0019   return parse_number(10u * n + static_cast<unsigned>(f - '0'), rest...);
0020 }
0021 } // namespace detail
0022 
0023 namespace literals {
0024 /// Suffix operator to generate literal compile-time numbers, 0_c, 12_c, etc.
0025 template <char... digits>
0026 auto operator"" _c() {
0027   return std::integral_constant<unsigned, detail::parse_number(0, digits...)>();
0028 }
0029 } // namespace literals
0030 } // namespace histogram
0031 } // namespace boost
0032 
0033 #endif