• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 // Copyright (C) 2008-2018 Lorenzo Caminiti
3 // Distributed under the Boost Software License, Version 1.0 (see accompanying
4 // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
5 // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html
6 
7 // Test with max possible number of bases.
8 
9 #include <boost/contract/public_function.hpp>
10 #include <boost/contract/base_types.hpp>
11 #include <boost/contract/check.hpp>
12 #include <boost/contract/override.hpp>
13 #include <boost/preprocessor/repetition/repeat.hpp>
14 #include <boost/preprocessor/repetition/enum.hpp>
15 #include <boost/preprocessor/cat.hpp>
16 
17 // Limited by max size of current impl of Boost.MPL vector.
18 #ifndef BOOST_CONTRACT_TEST_CONFIG_MAX_BASES
19     #define BOOST_CONTRACT_TEST_CONFIG_MAX_BASES 20
20 #endif
21 
22 #define BOOST_CONTRACT_TEST_base_decl(z, n, unused) \
23     struct BOOST_PP_CAT(b, n) { \
24         virtual void f(boost::contract::virtual_* v = 0) { \
25             boost::contract::check c = boost::contract::public_function( \
26                     v, this); \
27         } \
28     };
29 
30 BOOST_PP_REPEAT(BOOST_CONTRACT_TEST_CONFIG_MAX_BASES,
31         BOOST_CONTRACT_TEST_base_decl, ~)
32 
33 #define BOOST_CONTRACT_TEST_public_base(z, n, unused) public BOOST_PP_CAT(b, n)
34 
35 struct a
36     #define BASES \
37         BOOST_PP_ENUM(BOOST_CONTRACT_TEST_CONFIG_MAX_BASES, \
38                 BOOST_CONTRACT_TEST_public_base, ~)
39     : BASES
40 {
41     typedef BOOST_CONTRACT_BASE_TYPES(BASES) base_types;
42     #undef BASES
43 
fa44     void f(boost::contract::virtual_* v = 0) /* override */ {
45         boost::contract::check c = boost::contract::public_function<override_f>(
46                 v, &a::f, this);
47     }
48     BOOST_CONTRACT_OVERRIDE(f)
49 };
50 
main()51 int main() {
52     a aa;
53     aa.f();
54     return 0;
55 }
56 
57 #undef BOOST_CONTRACT_TEST_base_decl
58 #undef BOOST_CONTRACT_TEST_public_base
59 
60