#include <assert.h>

// Helper to map any type to void, needed by SFINAE below
template <typename T>
struct void_type {
    typedef void type;
};

// Selects a nested typedef or a default type D (using a macro to reduce boilerplate):
#define SELECT_NESTED_TYPE( TYPE )                                       \
template <typename T, typename D, typename _ = void>                     \
struct select_##TYPE{                                                    \
    typedef D type;                                                      \
};                                                                       \
template <typename T, typename D>                                        \
struct select_##TYPE<T, D, typename void_type<typename T::TYPE>::type> { \
    typedef typename T::TYPE type;                                       \
};                                                                      

SELECT_NESTED_TYPE( int_t );
SELECT_NESTED_TYPE( float_t );
//...
#undef SELECT_NESTED_TYPE

// Use
template <typename T>
class TheTemplate {
public:
   typedef typename select_int_t<T,int>::type int_t;
   typedef typename select_float_t<T,double>::type float_t;
   //....
};

// Test:
template <typename T, typename U> struct same_type {
   static const bool value = false;
};
template <typename T> struct same_type<T,T> {
   static const bool value = true;
};
struct test1 {
};
struct test2 {
   typedef long long int_t;
   typedef float float_t;
};
int main() {
   // test1 has the default typedefs
   assert(( same_type< TheTemplate<test1>::int_t, int>::value ));
   assert(( same_type< TheTemplate<test1>::float_t, double>::value ));
   // test2 has the ones in the type
   assert(( same_type< TheTemplate<test2>::int_t, long long>::value ));
   assert(( same_type< TheTemplate<test2>::float_t, float>::value ));
}