MADNESS  version 0.9
enable_if.h
Go to the documentation of this file.
1 /*
2  This file is part of MADNESS.
3 
4  Copyright (C) 2007,2010 Oak Ridge National Laboratory
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 
20  For more information please contact:
21 
22  Robert J. Harrison
23  Oak Ridge National Laboratory
24  One Bethel Valley Road
25  P.O. Box 2008, MS-6367
26 
27  email: harrisonrj@ornl.gov
28  tel: 865-241-3937
29  fax: 865-572-0680
30 
31 
32  $Id$
33 */
34 
35 #ifndef MADNESS_WORLD_ENABLE_IF_H__INCLUDED
36 #define MADNESS_WORLD_ENABLE_IF_H__INCLUDED
37 
38 namespace madness {
39 
41 
45  template <bool B, class returnT = void>
46  struct enable_if_c {
47  typedef returnT type;
48  };
49 
51  template <class returnT>
52  struct enable_if_c<false, returnT> {};
53 
55 
59  template <class Cond, class returnT = void>
60  struct enable_if : public enable_if_c<Cond::value, returnT> {};
61 
63 
67  template <bool B, class returnT = void>
68  struct disable_if_c {
69  typedef returnT type;
70  };
71 
73  template <class returnT>
74  struct disable_if_c<true, returnT> {};
75 
77  template <class Cond, class returnT = void>
78  struct disable_if : public disable_if_c<Cond::value, returnT> {};
79 
81 
86  template <bool B, class returnT>
88  typedef typename returnT::type type;
89  };
90 
92  template <class returnT>
93  struct lazy_enable_if_c<false, returnT> { };
94 
96 
101  template <class Cond, class returnT>
102  struct lazy_enable_if : public lazy_enable_if_c<Cond::value, returnT> { };
103 
105 
110  template <bool B, class returnT>
112  typedef typename returnT::type type;
113  };
114 
116  template <class returnT>
117  struct lazy_disable_if_c<true, returnT> {};
118 
120 
125  template <class Cond, class returnT>
126  struct lazy_disable_if : public lazy_disable_if_c<Cond::value, returnT> {};
127 
129 
134 // template <class T, class U, class returnT = void>
135 // struct enable_if_same : public enable_if<madness::is_same<T,U>, returnT> {};
136 
137  template <bool Cond, typename T1, typename T2>
138  struct if_c {
139  typedef T1 type;
140  };
141 
142  template <typename T1, typename T2>
143  struct if_c<false, T1, T2> {
144  typedef T2 type;
145  };
146 
147  template <typename Cond, typename T1, typename T2>
148  struct if_ : public if_c<Cond::value, T1, T2> {};
149 
150 
151 
152 } // namespace madness
153 
154 
155 /* Macros to make some of this stuff more readable */
156 
171 #define ENABLE_IF(CONDITION,TYPEIFTRUE) typename madness::enable_if< CONDITION, TYPEIFTRUE >::type
172 #define DISABLE_IF(CONDITION,TYPEIFTRUE) typename madness::disable_if< CONDITION, TYPEIFTRUE >::type
173 #define ENABLE_IF_SAME(A,B,TYPEIFTRUE) typename madness::enable_if<madness::is_same< A , B >, TYPEIFTRUE >::type
174 #define DISABLE_IF_SAME(A,B,TYPEIFTRUE) typename madness::disable_if<madness::is_same< A , B >, TYPEIFTRUE >::type
175 
176 #endif // MADNESS_WORLD_ENABLE_IF_H__INCLUDED
lazy_disable_if from Boost for conditionally instantiating templates based on type ...
Definition: enable_if.h:126
disable_if from Boost for conditionally instantiating templates based on type
Definition: enable_if.h:78
returnT type
Definition: enable_if.h:47
returnT::type type
Definition: enable_if.h:88
Definition: enable_if.h:148
returnT::type type
Definition: enable_if.h:112
enable_if_c from Boost for conditionally instantiating templates based on type
Definition: enable_if.h:46
lazy_enable_if from Boost for conditionally instantiating templates based on type ...
Definition: enable_if.h:102
T1 type
Definition: enable_if.h:139
T2 type
Definition: enable_if.h:144
lazy_disable_if_c from Boost for conditionally instantiating templates based on type ...
Definition: enable_if.h:111
disable_if from Boost for conditionally instantiating templates based on type
Definition: enable_if.h:68
returnT type
Definition: enable_if.h:69
enable_if_same (from Boost?) for conditionally instantiating templates if two types are equal ...
Definition: enable_if.h:138
lazy_enable_if_c from Boost for conditionally instantiating templates based on type ...
Definition: enable_if.h:87
enable_if from Boost for conditionally instantiating templates based on type
Definition: enable_if.h:60
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45