How do I make this simple addition code less verbose? I really don't get why it has to take so much to make such a little function. Here's what I have.

template &lt;typename A, typename B&gt; auto add(A a, B b) -&gt; decltype(a + b) {
   return a + b;
}


Is there a way to shrink this code while maintaining its ability to take different arguments? For a comparison, here is it in Python; there is a big difference between the two.

def add(a, b):
    return a + b
You may want to take a look at Pythy. 

What you want seems a lot like:

PYTHY(add, x, y) (
    return x + y;
)


Make sure to read this part of the article, as pointed out by Konrad:


  It appears that we are derefencing a null pointer. Remember in C++
  when dereferencing a null pointer, undefined behavior occurs when
  there is an rvalue-to-lvalue conversion. However, since a
  non-capturing lambda closure is almost always implemented as an object
  with no members, undefined behavior never occurs, since it won't
  access any of its members. Its highly unlikely that a non-capturing
  lambda closure could be implemented another way since it must be
  convertible to a function pointer. But perhaps not?