TMP and codebloat

How could we measured the relationship between types and binary files generated by
compilers?

1
2
3
4
5
6
7
8
9
10
11
12
13
template<typename T>
T Max(T const A, T const B)
{
  return A > B ? A : B;
}

void testMax()
{
  int a = 5, b = 10;
  double c = 44.4, d = 33.23;
  Max(a, b);
  Max(c, d);
}

is same as
1
2
3
4
5
6
7
8
9
int Max(int const A, int const B)
{
  return A > B ? A : B;
}

double Max(double const A, double const B)
{
  return A > B ? A : B;
}

Ok, I know I could ask the compiler to generate the "Max" I need
and it is same as handcrafted codes
but what about this
 
typedef boost::mpl::vector<int, double, char, size_t, long double>  complex_types;

would the complex_types consume more binary codes to save the types than
primitive types?

Besides, when we do something like TMP like this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class NullType;

template<typename T, typename U>
class Typelist
{
  typedef T Head;
  typedef U Tail;
};

template<typename TList>
class length;

template<>
class length<NullType>
{
  public :
    enum{ Value = 0 };
};

template<typename Head, typename Tail>
class length<Typelist<Head, Tail> >
{
  public :
    enum { Value = 1 + length<Tail>::Value };
};


what we really get is an enumerator constant "Value"
would those recursive steps generate binary codes too?
Or compiler would optimize it?
Thanks
Topic archived. No new replies allowed.