00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __BIN_POW_HH
00019 # define __BIN_POW_HH
00020
00021 # include <type_traits>
00022
00023 namespace fast {
00024
00025 template <typename integral_type, typename N>
00026 struct bin_pow_wrapped: public
00027 std::integral_constant<integral_type,
00028 bin_pow_wrapped<integral_type,
00029 std::integral_constant<integral_type,
00030 N::value-1>
00031 >::value*2> {};
00032
00033 template <typename integral_type>
00034 struct bin_pow_wrapped<integral_type,
00035 std::integral_constant<integral_type, 0> >
00036 : public std::integral_constant<integral_type, 1> {};
00037
00038 template <typename integral_type, integral_type N>
00039 struct bin_pow:
00040 public bin_pow_wrapped<integral_type,
00041 std::integral_constant<integral_type, N> > {};
00042
00043 template <typename integral_type, integral_type N>
00044 struct bin_pow_pow {
00045 enum: integral_type {
00046 value = bin_pow<integral_type, bin_pow<integral_type, N-1>::value>
00047 ::value
00048 };
00049 };
00050 }
00051
00052 #endif