100db7afdSDavid E. O'Brien // Concept-checking control -*- C++ -*- 200db7afdSDavid E. O'Brien 300db7afdSDavid E. O'Brien // Copyright (C) 2001 Free Software Foundation, Inc. 400db7afdSDavid E. O'Brien // 500db7afdSDavid E. O'Brien // This file is part of the GNU ISO C++ Library. This library is free 600db7afdSDavid E. O'Brien // software; you can redistribute it and/or modify it under the 700db7afdSDavid E. O'Brien // terms of the GNU General Public License as published by the 800db7afdSDavid E. O'Brien // Free Software Foundation; either version 2, or (at your option) 900db7afdSDavid E. O'Brien // any later version. 1000db7afdSDavid E. O'Brien 1100db7afdSDavid E. O'Brien // This library is distributed in the hope that it will be useful, 1200db7afdSDavid E. O'Brien // but WITHOUT ANY WARRANTY; without even the implied warranty of 1300db7afdSDavid E. O'Brien // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1400db7afdSDavid E. O'Brien // GNU General Public License for more details. 1500db7afdSDavid E. O'Brien 1600db7afdSDavid E. O'Brien // You should have received a copy of the GNU General Public License along 1700db7afdSDavid E. O'Brien // with this library; see the file COPYING. If not, write to the Free 18*f8a1b7d9SAlexander Kabaev // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 1900db7afdSDavid E. O'Brien // USA. 2000db7afdSDavid E. O'Brien 2100db7afdSDavid E. O'Brien // As a special exception, you may use this file as part of a free software 2200db7afdSDavid E. O'Brien // library without restriction. Specifically, if other files instantiate 2300db7afdSDavid E. O'Brien // templates or use macros or inline functions from this file, or you compile 2400db7afdSDavid E. O'Brien // this file and link it with other files to produce an executable, this 2500db7afdSDavid E. O'Brien // file does not by itself cause the resulting executable to be covered by 2600db7afdSDavid E. O'Brien // the GNU General Public License. This exception does not however 2700db7afdSDavid E. O'Brien // invalidate any other reasons why the executable file might be covered by 2800db7afdSDavid E. O'Brien // the GNU General Public License. 2900db7afdSDavid E. O'Brien 3000db7afdSDavid E. O'Brien /** @file concept_check.h 3100db7afdSDavid E. O'Brien * This is an internal header file, included by other library headers. 3200db7afdSDavid E. O'Brien * You should not attempt to use it directly. 3300db7afdSDavid E. O'Brien */ 3400db7afdSDavid E. O'Brien 35ffeaf689SAlexander Kabaev #ifndef _CONCEPT_CHECK_H 36ffeaf689SAlexander Kabaev #define _CONCEPT_CHECK_H 1 3700db7afdSDavid E. O'Brien 3800db7afdSDavid E. O'Brien #pragma GCC system_header 3900db7afdSDavid E. O'Brien 4000db7afdSDavid E. O'Brien #include <bits/c++config.h> 4100db7afdSDavid E. O'Brien 4200db7afdSDavid E. O'Brien // All places in libstdc++-v3 where these are used, or /might/ be used, or 4300db7afdSDavid E. O'Brien // don't need to be used, or perhaps /should/ be used, are commented with 4400db7afdSDavid E. O'Brien // "concept requirements" (and maybe some more text). So grep like crazy 4500db7afdSDavid E. O'Brien // if you're looking for additional places to use these. 4600db7afdSDavid E. O'Brien 4700db7afdSDavid E. O'Brien // Concept-checking code is off by default unless users turn it on via 4800db7afdSDavid E. O'Brien // configure options or editing c++config.h. 4900db7afdSDavid E. O'Brien 50ffeaf689SAlexander Kabaev #ifndef _GLIBCXX_CONCEPT_CHECKS 5100db7afdSDavid E. O'Brien 52ffeaf689SAlexander Kabaev #define __glibcxx_function_requires(...) 53ffeaf689SAlexander Kabaev #define __glibcxx_class_requires(_a,_b) 54ffeaf689SAlexander Kabaev #define __glibcxx_class_requires2(_a,_b,_c) 55ffeaf689SAlexander Kabaev #define __glibcxx_class_requires3(_a,_b,_c,_d) 56ffeaf689SAlexander Kabaev #define __glibcxx_class_requires4(_a,_b,_c,_d,_e) 5700db7afdSDavid E. O'Brien 5800db7afdSDavid E. O'Brien #else // the checks are on 5900db7afdSDavid E. O'Brien 6000db7afdSDavid E. O'Brien #include <bits/boost_concept_check.h> 6100db7afdSDavid E. O'Brien 6200db7afdSDavid E. O'Brien // Note that the obvious and elegant approach of 6300db7afdSDavid E. O'Brien // 64ffeaf689SAlexander Kabaev //#define glibcxx_function_requires(C) boost::function_requires< boost::C >() 6500db7afdSDavid E. O'Brien // 6600db7afdSDavid E. O'Brien // won't work due to concept templates with more than one parameter, e.g., 6700db7afdSDavid E. O'Brien // BinaryPredicateConcept. The preprocessor tries to split things up on 6800db7afdSDavid E. O'Brien // the commas in the template argument list. We can't use an inner pair of 6900db7afdSDavid E. O'Brien // parenthesis to hide the commas, because "boost::(Temp<Foo,Bar>)" isn't 7000db7afdSDavid E. O'Brien // a valid instantiation pattern. Thus, we steal a feature from C99. 7100db7afdSDavid E. O'Brien 72ffeaf689SAlexander Kabaev #define __glibcxx_function_requires(...) \ 7300db7afdSDavid E. O'Brien __gnu_cxx::__function_requires< __gnu_cxx::__VA_ARGS__ >(); 74ffeaf689SAlexander Kabaev #define __glibcxx_class_requires(_a,_C) \ 75ffeaf689SAlexander Kabaev _GLIBCXX_CLASS_REQUIRES(_a, __gnu_cxx, _C); 76ffeaf689SAlexander Kabaev #define __glibcxx_class_requires2(_a,_b,_C) \ 77ffeaf689SAlexander Kabaev _GLIBCXX_CLASS_REQUIRES2(_a, _b, __gnu_cxx, _C); 78ffeaf689SAlexander Kabaev #define __glibcxx_class_requires3(_a,_b,_c,_C) \ 79ffeaf689SAlexander Kabaev _GLIBCXX_CLASS_REQUIRES3(_a, _b, _c, __gnu_cxx, _C); 80ffeaf689SAlexander Kabaev #define __glibcxx_class_requires4(_a,_b,_c,_d,_C) \ 81ffeaf689SAlexander Kabaev _GLIBCXX_CLASS_REQUIRES4(_a, _b, _c, _d, __gnu_cxx, _C); 8200db7afdSDavid E. O'Brien 8300db7afdSDavid E. O'Brien #endif // enable/disable 8400db7afdSDavid E. O'Brien 85ffeaf689SAlexander Kabaev #endif // _GLIBCXX_CONCEPT_CHECK 86