tinympl  0.2
mini MPL library for C++11
at.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_VARIADIC_AT_HPP
14 #define TINYMPL_VARIADIC_AT_HPP
15 
16 #include <cstddef>
17 
18 namespace tinympl {
19 namespace variadic {
20 
27 template<int i,class ... Args> struct at;
28 
29 template<int i,class ... Args> using at_t = typename at<i,Args...>::type;
30 
31 template<int i,class Head,class ... Tail> struct at<i,Head,Tail...>
32 {
33  static_assert(i < sizeof ... (Tail) + 1,"Index out of range");
34  typedef typename at<i-1,Tail...>::type type;
35 };
36 
37 template<class Head,class ... Tail> struct at<0,Head,Tail...>
38 {
39  typedef Head type;
40 };
41 
42 } // namespace variadic
43 } // namespace tinympl
44 
45 #endif // TINYMPL_VARIADIC_AT_HPP
Extract the i-th element of a variadic template.
Definition: at.hpp:27