static_def.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. #include <cstdio>
  8. #include "static_def.hpp"
  9. extern int f();
  10. extern void* f_sum_lambda_addr();
  11. extern void* f_sum_fo_addr();
  12. extern void* sum_lambda_addr();
  13. extern void* sum_fo_addr();
  14. extern void* f_sum_var_addr();
  15. extern void* f_sum_constexpr_fo_addr();
  16. extern void* sum_var_addr();
  17. extern void* sum_constexpr_fo_addr();
  18. void* sum_lambda_addr()
  19. {
  20. return (void*)&fit_test::fit_sum_lambda;
  21. }
  22. void* sum_fo_addr()
  23. {
  24. return (void*)&fit_test::fit_sum_fo;
  25. }
  26. void* sum_var_addr()
  27. {
  28. return (void*)&fit_test::fit_sum_var;
  29. }
  30. void* sum_constexpr_fo_addr()
  31. {
  32. return (void*)&fit_test::fit_sum_constexpr_fo;
  33. }
  34. int main()
  35. {
  36. if (fit_test::fit_sum_fo(1, 2) != 3) printf("FAILED\n");
  37. if (fit_test::fit_sum_lambda(1, 2) != 3) printf("FAILED\n");
  38. if (fit_test::fit_sum(1, 2) != 3) printf("FAILED\n");
  39. #if BOOST_HOF_HAS_UNIQUE_STATIC_LAMBDA_FUNCTION_ADDR
  40. if (sum_lambda_addr() != f_sum_lambda_addr()) printf("FAILED: Lambda\n");
  41. if (sum_fo_addr() != f_sum_fo_addr()) printf("FAILED: Function object\n");
  42. #endif
  43. #if BOOST_HOF_HAS_UNIQUE_STATIC_VAR
  44. if (sum_var_addr() != f_sum_var_addr()) printf("FAILED: Lambda\n");
  45. if (sum_constexpr_fo_addr() != f_sum_constexpr_fo_addr()) printf("FAILED: Function object\n");
  46. #endif
  47. return f();
  48. }