Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template <int N>
- struct Factorial
- {
- enum { value = N * Factorial<N - 1>::value };
- };
- template <>
- struct Factorial<0>
- {
- enum { value = 1 };
- };
- // Factorial<4>::value == 24
- // Factorial<0>::value == 1
- void foo()
- {
- int x = Factorial<4>::value; // == 24
- int y = Factorial<0>::value; // == 1
- }
- template <unsigned target, unsigned mask>
- struct _mask_merger
- {
- enum
- {
- ROW0 = ((target >> (((mask >> 0) & 3) << 1)) & 3) << 0,
- ROW1 = ((target >> (((mask >> 2) & 3) << 1)) & 3) << 2,
- ROW2 = ((target >> (((mask >> 4) & 3) << 1)) & 3) << 4,
- ROW3 = ((target >> (((mask >> 6) & 3) << 1)) & 3) << 6,
- MASK = ROW0 | ROW1 | ROW2 | ROW3,
- };
- };
- template <typename T>
- struct value_type {
- typedef typename T::value_type type;
- };
- template <typename T>
- struct value_type<T*> {
- typedef T type;
- };
- template< unsigned long long N >
- struct binary
- {
- enum { value = (N % 10) + 2 * binary< N / 10 > :: value } ;
- };
- template<>
- struct binary< 0 >
- {
- enum { value = 0 } ;
- };
- double innerLoop(const bool b, const vector<double> & v)
- {
- // some logic involving b
- for (vector::const_iterator it = v.begin; it != v.end(); ++it)
- {
- // significant logic involving b
- }
- // more logic involving b
- return ....
- }
- template <bool b> double innerLoop_B(vector<double> v) { ... same as before ... }
- double innerLoop(const bool b, const vector<double> & v)
- { return b ? innerLoop_templ_B<true>(v) : innerLoop_templ_B<false>(v) ); }
- typedef
- type_list_generator< signed char
- , signed short
- , signed int
- , signed long
- >::result_type
- signed_int_type_list;
- typedef
- type_list_find_if< signed_int_type_list
- , exact_size_predicate<8>
- >::result_type
- int8_t;
- typedef
- type_list_find_if< signed_int_type_list
- , exact_size_predicate<16>
- >::result_type
- int16_t;
- typedef
- type_list_find_if< signed_int_type_list
- , exact_size_predicate<32>
- >::result_type
- int32_t;
- template< typename TFunc, typename TFwdIter >
- typename func_traits<TFunc>::result_t callFunc(TFunc f, TFwdIter begin, TFwdIter end);
Add Comment
Please, Sign In to add comment