• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Copyright (c) 2017 Paul Fultz II
3     static_def.cpp
4     Distributed under the Boost Software License, Version 1.0. (See accompanying
5     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7 
8 #include <cstdio>
9 #include "static_def.hpp"
10 
11 extern int f();
12 
13 extern void* f_sum_lambda_addr();
14 extern void* f_sum_fo_addr();
15 
16 extern void* sum_lambda_addr();
17 extern void* sum_fo_addr();
18 
19 extern void* f_sum_var_addr();
20 extern void* f_sum_constexpr_fo_addr();
21 
22 extern void* sum_var_addr();
23 extern void* sum_constexpr_fo_addr();
24 
sum_lambda_addr()25 void* sum_lambda_addr()
26 {
27     return (void*)&fit_test::fit_sum_lambda;
28 }
sum_fo_addr()29 void* sum_fo_addr()
30 {
31     return (void*)&fit_test::fit_sum_fo;
32 }
33 
sum_var_addr()34 void* sum_var_addr()
35 {
36     return (void*)&fit_test::fit_sum_var;
37 }
sum_constexpr_fo_addr()38 void* sum_constexpr_fo_addr()
39 {
40     return (void*)&fit_test::fit_sum_constexpr_fo;
41 }
42 
main()43 int main()
44 {
45     if (fit_test::fit_sum_fo(1, 2) != 3) printf("FAILED\n");
46     if (fit_test::fit_sum_lambda(1, 2) != 3) printf("FAILED\n");
47     if (fit_test::fit_sum(1, 2) != 3) printf("FAILED\n");
48 
49 #if BOOST_HOF_HAS_UNIQUE_STATIC_LAMBDA_FUNCTION_ADDR
50     if (sum_lambda_addr() != f_sum_lambda_addr()) printf("FAILED: Lambda\n");
51     if (sum_fo_addr() != f_sum_fo_addr()) printf("FAILED: Function object\n");
52 #endif
53 
54 #if BOOST_HOF_HAS_UNIQUE_STATIC_VAR
55     if (sum_var_addr() != f_sum_var_addr()) printf("FAILED: Lambda\n");
56     if (sum_constexpr_fo_addr() != f_sum_constexpr_fo_addr()) printf("FAILED: Function object\n");
57 #endif
58     return f();
59 }
60