Is the following statement an overload function or a partial specialization of a function?

template <typename Function> void for_each_element(
  const boost::tuples::null_type&, Function) {}

template <typename Tuple, typename Function> void     
  for_each_element(Tuple& t, Function func) {
    func(t.get_head());
    for_each_element(t.get_tail(),func);
}

Given the above code snippet, do we define an overload function or a partially specialized function?

thank

+3
source share
3 answers

There is no such thing as a partial specialization function. This is an overload.

eg.

template <typename T, typename U>
void foo(T t, U u);

template <typename T>
void foo<T, int>(T t, int u); // Illegal: no partial specialisation of functions

template <typename T>
void foo(T t, int u); // OK

Be careful when specializing with overloads , as this does not always work the way you think.

+5
source

Overload. You cannot partially specialize functions, and even if you could, you would have a second pair of <>security.

0
source

This is an overload. Partial specialization of functions is not possible. If you try to partially specialize a function, the compiler will complain. In this case, when you reach the end of the tuple, the compiler uses the overload resolution to select the first function.

0
source

All Articles