| 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 | |
| 25 | void* sum_lambda_addr() |
| 26 | { |
| 27 | return (void*)&fit_test::fit_sum_lambda; |
| 28 | } |
| 29 | void* sum_fo_addr() |
| 30 | { |
| 31 | return (void*)&fit_test::fit_sum_fo; |
| 32 | } |
| 33 | |
| 34 | void* sum_var_addr() |
| 35 | { |
| 36 | return (void*)&fit_test::fit_sum_var; |
| 37 | } |
| 38 | void* sum_constexpr_fo_addr() |
| 39 | { |
| 40 | return (void*)&fit_test::fit_sum_constexpr_fo; |
| 41 | } |
| 42 | |
| 43 | int main() |
| 44 | { |
| 45 | if (fit_test::fit_sum_fo(1, 2) != 3) printf(format: "FAILED\n"); |
| 46 | if (fit_test::fit_sum_lambda(1, 2) != 3) printf(format: "FAILED\n"); |
| 47 | if (fit_test::fit_sum(x: 1, y: 2) != 3) printf(format: "FAILED\n"); |
| 48 | |
| 49 | #if BOOST_HOF_HAS_UNIQUE_STATIC_LAMBDA_FUNCTION_ADDR |
| 50 | if (sum_lambda_addr() != f_sum_lambda_addr()) printf(format: "FAILED: Lambda\n"); |
| 51 | if (sum_fo_addr() != f_sum_fo_addr()) printf(format: "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(format: "FAILED: Lambda\n"); |
| 56 | if (sum_constexpr_fo_addr() != f_sum_constexpr_fo_addr()) printf(format: "FAILED: Function object\n"); |
| 57 | #endif |
| 58 | return f(); |
| 59 | } |
| 60 |
