typedef int AccT; }; template<> class AccumulationTraits<short> { public: typedef int AccT; }; template<> class AccumulationTraits<int> { public: typedef long AccT; }; // unsigned int -> unsigned long // float -> double // .....
typedef _Arg1 first_argument_type; ///< the type of the first argument /// (no surprises here) typedef _Arg2 second_argument_type; ///< the type of the second argument typedef _Result result_type; ///< type of the return type }; template <class _Tp> struct plus : public binary_function<_Tp, _Tp, _Tp> { _Tp operator()(const _Tp& __x, const _Tp& __y) const { return __x + __y; } };
N> class Sqrt { public: enum { mid = (LO + HI + 1) / 2 }; typedef typename IfThenElse<(N < mid * mid), Sqrt<N,LO,mid-1>, Sqrt<N,mid,HI> >::ResultT SubT; enum { result = SubT::result }; }; template <int N, int M> class Sqrt<N,M,M> { public: enum { result = M }; }; template <bool C, typename Ta, typename Tb> class IfThenElse; template <typename Ta, typename Tb> class IfThenElse<true, Ta, Tb> { public: typedef Ta ResultT; }; template <typename Ta, typename Tb> class IfThenElse<false, Ta, Tb> { public: typedef Tb ResultT; }; Только одно инстанцирование