MPQC 3.0.0-alpha
Loading...
Searching...
No Matches
meta.h
1//
2// meta.h
3//
4// Copyright (C) 2014 David Hollman
5//
6// Author: David Hollman
7// Maintainer: DSH
8// Created: Feb 11, 2014
9//
10// This file is part of the SC Toolkit.
11//
12// The SC Toolkit is free software; you can redistribute it and/or modify
13// it under the terms of the GNU Library General Public License as published by
14// the Free Software Foundation; either version 2, or (at your option)
15// any later version.
16//
17// The SC Toolkit is distributed in the hope that it will be useful,
18// but WITHOUT ANY WARRANTY; without even the implied warranty of
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20// GNU Library General Public License for more details.
21//
22// You should have received a copy of the GNU Library General Public License
23// along with the SC Toolkit; see the file COPYING.LIB. If not, write to
24// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
25//
26// The U.S. Government is granted a limited license as per AL 91-7.
27//
28
29#ifndef _util_misc_meta_h
30#define _util_misc_meta_h
31
32// Boost includes
33#include <boost/mpl/back.hpp>
34#include <boost/mpl/pop_back.hpp>
35#include <boost/mpl/empty.hpp>
36
37namespace sc { namespace meta {
38
39namespace mpl = boost::mpl;
40
42// splat: a metafunction for "splatting" a boost::mpl::vector (or any other
43// boost::mpl Front Extensible Sequence) into variadic arguments of another
44// metafunction or type.
45
46
47namespace { // anonymous namespace to hide splat_helper from outside world
48
49 template<template<typename...> class T, bool empty, typename C, typename... Types>
50 struct splat_helper {
51 typedef typename mpl::pop_back<C>::type rest;
52 typedef typename splat_helper<
53 T, mpl::empty<rest>::value, rest, typename mpl::back<C>::type, Types...
54 >::type type;
55 };
56
57 template<template<typename...> class T, typename C, typename... Types>
58 struct splat_helper<T, true, C, Types...> {
59 typedef T<Types...> type;
60 };
61
62 template<typename value_type, template<value_type...> class T, bool empty, typename C, value_type... values>
63 struct splat_helper_values {
64 typedef typename mpl::pop_back<C>::type rest;
65 typedef typename splat_helper_values<
66 value_type, T, mpl::empty<rest>::value, rest, mpl::back<C>::type::value, values...
67 >::type type;
68 };
69
70 template<typename value_type, template<value_type...> class T, typename C, value_type... values>
71 struct splat_helper_values<value_type, T, true, C, values...> {
72 typedef T<values...> type;
73 };
74
75} // end anonymous namespace
76
77template<template<typename...> class T, typename C>
79 : splat_helper<T, mpl::empty<C>::value, C>
80{ };
81
82// Container contains types with a value attribute that is an int
83template<typename value_type, template<value_type...> class T, typename C>
85 : splat_helper_values<value_type, T, mpl::empty<C>::value, C>
86{ };
87
88
89
91
92} } // end namespace sc::meta
93
94#endif /* _util_misc_meta_h */
Contains all MPQC code up to version 3.
Definition mpqcin.h:14
Definition meta.h:80
Definition meta.h:86

Generated at Wed Sep 25 2024 02:45:31 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.12.0.