tinympl  0.2
mini MPL library for C++11
erase.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_ERASE_HPP
14 #define TINYMPL_VARIADIC_ERASE_HPP
15 
16 #include <cstddef>
17 
18 namespace tinympl {
19 namespace variadic {
20 
30 template<std::size_t start,std::size_t end,template<class ...> class Out,class ... Args> struct erase;
31 
32 template<std::size_t start,std::size_t end,template<class ...> class Out,class ... Args> using erase_t = typename erase<start,end,Out,Args...>::type;
33 
34 template<std::size_t start,std::size_t end,template<class ...> class Out,class Head,class ... Args> struct erase<start,end,Out,Head,Args...>
35 {
36 private:
37  template<class ... CopiedElements>
38  struct impl
39  {
40  typedef typename erase<start-1,end-1,Out,Args...>::template impl<CopiedElements...,Head>::type type;
41  };
42 
43  template<std::size_t,std::size_t,template<class ...> class,class ...> friend struct erase;
44 
45 public:
46  static_assert(start <= end,"Start > end!");
47 
48  typedef typename impl<>::type type;
49 };
50 
51 template<std::size_t end,template<class ...> class Out,class Head,class ... Args> struct erase<0,end,Out,Head,Args...>
52 {
53 private:
54  template<class ... CopiedElements>
55  struct impl
56  {
57  typedef typename erase<0,end-1,Out,Args...>::template impl<CopiedElements...>::type type;
58  };
59 
60  template<std::size_t,std::size_t,template<class ...> class,class ...> friend struct erase;
61 
62 public:
63  typedef typename impl<>::type type;
64 };
65 
66 template<template<class ...> class Out,class Head,class ... Args> struct erase<0,0,Out,Head,Args...>
67 {
68 private:
69  template<class ... CopiedElements>
70  struct impl
71  {
72  typedef Out<CopiedElements..., Head,Args...> type;
73  };
74 
75  template<std::size_t,std::size_t,template<class ...> class,class ...> friend struct erase;
76 
77 public:
78  typedef typename impl<>::type type;
79 };
80 
81 template<template<class ...> class Out> struct erase<0,0,Out>
82 {
83 private:
84  template<class ... CopiedElements>
85  struct impl
86  {
87  typedef Out<CopiedElements...> type;
88  };
89 
90  template<std::size_t,std::size_t,template<class ...> class,class ...> friend struct erase;
91 
92 public:
93  typedef typename impl<>::type type;
94 };
95 
96 } // namespace variadic
97 } // namespace tinympl
98 
99 #endif // TINYMPL_VARIADIC_ERASE_HPP
Produce an output sequence from a variadic template by removin the elements in the given range...
Definition: erase.hpp:30