xref: /dflybsd-src/contrib/gcc-8.0/libstdc++-v3/include/bits/concept_check.h (revision 38fd149817dfbff97799f62fcb70be98c4e32523)
1*38fd1498Szrj // Concept-checking control -*- C++ -*-
2*38fd1498Szrj 
3*38fd1498Szrj // Copyright (C) 2001-2018 Free Software Foundation, Inc.
4*38fd1498Szrj //
5*38fd1498Szrj // This file is part of the GNU ISO C++ Library.  This library is free
6*38fd1498Szrj // software; you can redistribute it and/or modify it under the
7*38fd1498Szrj // terms of the GNU General Public License as published by the
8*38fd1498Szrj // Free Software Foundation; either version 3, or (at your option)
9*38fd1498Szrj // any later version.
10*38fd1498Szrj 
11*38fd1498Szrj // This library is distributed in the hope that it will be useful,
12*38fd1498Szrj // but WITHOUT ANY WARRANTY; without even the implied warranty of
13*38fd1498Szrj // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*38fd1498Szrj // GNU General Public License for more details.
15*38fd1498Szrj 
16*38fd1498Szrj // Under Section 7 of GPL version 3, you are granted additional
17*38fd1498Szrj // permissions described in the GCC Runtime Library Exception, version
18*38fd1498Szrj // 3.1, as published by the Free Software Foundation.
19*38fd1498Szrj 
20*38fd1498Szrj // You should have received a copy of the GNU General Public License and
21*38fd1498Szrj // a copy of the GCC Runtime Library Exception along with this program;
22*38fd1498Szrj // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23*38fd1498Szrj // <http://www.gnu.org/licenses/>.
24*38fd1498Szrj 
25*38fd1498Szrj /** @file bits/concept_check.h
26*38fd1498Szrj  *  This is an internal header file, included by other library headers.
27*38fd1498Szrj  *  Do not attempt to use it directly. @headername{iterator}
28*38fd1498Szrj  */
29*38fd1498Szrj 
30*38fd1498Szrj #ifndef _CONCEPT_CHECK_H
31*38fd1498Szrj #define _CONCEPT_CHECK_H 1
32*38fd1498Szrj 
33*38fd1498Szrj #pragma GCC system_header
34*38fd1498Szrj 
35*38fd1498Szrj #include <bits/c++config.h>
36*38fd1498Szrj 
37*38fd1498Szrj // All places in libstdc++-v3 where these are used, or /might/ be used, or
38*38fd1498Szrj // don't need to be used, or perhaps /should/ be used, are commented with
39*38fd1498Szrj // "concept requirements" (and maybe some more text).  So grep like crazy
40*38fd1498Szrj // if you're looking for additional places to use these.
41*38fd1498Szrj 
42*38fd1498Szrj // Concept-checking code is off by default unless users turn it on via
43*38fd1498Szrj // configure options or editing c++config.h.
44*38fd1498Szrj // It is not supported for freestanding implementations.
45*38fd1498Szrj 
46*38fd1498Szrj #if !defined(_GLIBCXX_CONCEPT_CHECKS) || !_GLIBCXX_HOSTED
47*38fd1498Szrj 
48*38fd1498Szrj #define __glibcxx_function_requires(...)
49*38fd1498Szrj #define __glibcxx_class_requires(_a,_b)
50*38fd1498Szrj #define __glibcxx_class_requires2(_a,_b,_c)
51*38fd1498Szrj #define __glibcxx_class_requires3(_a,_b,_c,_d)
52*38fd1498Szrj #define __glibcxx_class_requires4(_a,_b,_c,_d,_e)
53*38fd1498Szrj 
54*38fd1498Szrj #else // the checks are on
55*38fd1498Szrj 
56*38fd1498Szrj #include <bits/boost_concept_check.h>
57*38fd1498Szrj 
58*38fd1498Szrj // Note that the obvious and elegant approach of
59*38fd1498Szrj //
60*38fd1498Szrj //#define glibcxx_function_requires(C) debug::function_requires< debug::C >()
61*38fd1498Szrj //
62*38fd1498Szrj // won't work due to concept templates with more than one parameter, e.g.,
63*38fd1498Szrj // BinaryPredicateConcept.  The preprocessor tries to split things up on
64*38fd1498Szrj // the commas in the template argument list.  We can't use an inner pair of
65*38fd1498Szrj // parenthesis to hide the commas, because "debug::(Temp<Foo,Bar>)" isn't
66*38fd1498Szrj // a valid instantiation pattern.  Thus, we steal a feature from C99.
67*38fd1498Szrj 
68*38fd1498Szrj #define __glibcxx_function_requires(...)                                 \
69*38fd1498Szrj             __gnu_cxx::__function_requires< __gnu_cxx::__VA_ARGS__ >();
70*38fd1498Szrj #define __glibcxx_class_requires(_a,_C)                                  \
71*38fd1498Szrj             _GLIBCXX_CLASS_REQUIRES(_a, __gnu_cxx, _C);
72*38fd1498Szrj #define __glibcxx_class_requires2(_a,_b,_C)                              \
73*38fd1498Szrj             _GLIBCXX_CLASS_REQUIRES2(_a, _b, __gnu_cxx, _C);
74*38fd1498Szrj #define __glibcxx_class_requires3(_a,_b,_c,_C)                           \
75*38fd1498Szrj             _GLIBCXX_CLASS_REQUIRES3(_a, _b, _c, __gnu_cxx, _C);
76*38fd1498Szrj #define __glibcxx_class_requires4(_a,_b,_c,_d,_C)                        \
77*38fd1498Szrj             _GLIBCXX_CLASS_REQUIRES4(_a, _b, _c, _d, __gnu_cxx, _C);
78*38fd1498Szrj 
79*38fd1498Szrj #endif // enable/disable
80*38fd1498Szrj 
81*38fd1498Szrj #endif // _GLIBCXX_CONCEPT_CHECK
82