tinympl  0.2
mini MPL library for C++11
right_fold.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_RIGHT_FOLD_HPP
14 #define TINYMPL_VARIADIC_RIGHT_FOLD_HPP
15 
16 namespace tinympl {
17 namespace variadic {
18 
28 template<template<class ...> class Op, class ... Args> struct right_fold;
29 
30 template<template<class ...> class Op, class Head, class ... Tail>
31 struct right_fold<Op, Head, Tail...> {
32  typedef typename Op < Head,
33  typename right_fold<Op, Tail...>::type >::type type;
34 };
35 
36 template<template<class ...> class Op, typename T> struct right_fold<Op, T> {
37  typedef T type;
38 };
39 
40 } // namespace variadic
41 } // namespace tinympl
42 
43 #endif // TINYMPL_VARIADIC_RIGHT_FOLD_HPP
Collapses a sequence starting from right using a functor.
Definition: right_fold.hpp:28