tinympl  0.2
mini MPL library for C++11
plus.hpp
1 // Copyright (C) 2013, Ennio Barbaro.
2 //
3 // Use, modification, and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // See http://sbabbi.github.io/tinympl for documentation.
8 //
9 // You are welcome to contact the author at:
10 // enniobarbaro@gmail.com
11 //
12 
13 #ifndef TINYMPL_PLUS_HPP
14 #define TINYMPL_PLUS_HPP
15 
16 #include <type_traits>
17 
18 namespace tinympl {
19 
26 template<class ... Args> struct plus;
27 template<class Head,class ... Tail> struct plus<Head,Tail...> : plus<Head, typename plus<Tail...>::type> {};
28 
29 template<class A,class B> struct plus<A,B> :
30  std::integral_constant<
31  typename std::common_type<
32  typename A::value_type,
33  typename B::value_type
34  >::type, A::value + B::value>
35 {};
36 
37 template<class Head> struct plus<Head> : std::integral_constant<typename Head::value_type,Head::value> {};
38 
39 } // namespace tinympl
40 
41 #endif // TINYMPL_PLUS_HPP
Sums its arguments.
Definition: plus.hpp:26