static_def2.cpp 1.6 KB

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