//userliteral header //Copyright (c) 2014 mmYYmmdd #if !defined MMYYMMDD_USER_LITERAL_INCLUDED #define MMYYMMDD_USER_LITERAL_INCLUDED #include // create std::integral_constant and std::ratio from user defined literal // ユーザー定義リテラルから std::integral_constant と std::ratio を出力する namespace mymd { namespace detail_user_literal { constexpr std::size_t buncho(char x) { return ('0' <= x && x <= '9')? x-'0': ('a' <= x && x <='f' )? x-'a'+10: ('A' <= x && x <='F' )? x-'A'+10: 0; } template struct digit; template struct digit { static constexpr std::size_t num = digit::num; static constexpr std::size_t den = digit::den; }; template struct digit { static constexpr std::size_t num = digit<16, 0, D, tail...>::num; static constexpr std::size_t den = digit<16, 0, D, tail...>::den; }; template struct digit { static constexpr std::size_t num = digit<16, 0, D, tail...>::num; static constexpr std::size_t den = digit<16, 0, D, tail...>::den; }; template struct digit { static constexpr std::size_t num = digit<2, 0, D, tail...>::num; static constexpr std::size_t den = digit<2, 0, D, tail...>::den; }; template struct digit { static constexpr std::size_t num = digit<2, 0, D, tail...>::num; static constexpr std::size_t den = digit<2, 0, D, tail...>::den; }; template struct digit { static constexpr std::size_t num = digit::num; static constexpr std::size_t den = digit::den; }; template struct digit { constexpr static std::size_t num = N; constexpr static std::size_t den = D; }; template constexpr int num() { return digit::num; } template constexpr int den() { return digit::den == 0? 1: digit::den; } } //namespace detail_user_literal namespace ul { template constexpr auto operator "" _ic() ->std::integral_constant() / detail_user_literal::den()> { return std::integral_constant() / detail_user_literal::den()>{}; } template constexpr auto operator "" _rc() ->std::ratio(), detail_user_literal::den()> { return std::ratio(), detail_user_literal::den()>{}; } } // namespace ul } // namespace mymd #endif