operator.cpp 991 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright (C) 2009-2012 Lorenzo Caminiti
  2. // Distributed under the Boost Software License, Version 1.0
  3. // (see accompanying file LICENSE_1_0.txt or a copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // Home at http://www.boost.org/libs/local_function
  6. #include <boost/config.hpp>
  7. #ifdef BOOST_NO_CXX11_VARIADIC_MACROS
  8. # error "variadic macros required"
  9. #else
  10. #include <boost/local_function.hpp>
  11. #include <boost/typeof/typeof.hpp>
  12. #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
  13. #include <boost/detail/lightweight_test.hpp>
  14. //[operator
  15. struct point {
  16. int x;
  17. int y;
  18. };
  19. BOOST_TYPEOF_REGISTER_TYPE(point) // Register for `NAME` below.
  20. int main(void) {
  21. bool BOOST_LOCAL_FUNCTION(const point& p, const point& q) {
  22. return p.x == q.x && p.y == q.y;
  23. } BOOST_LOCAL_FUNCTION_NAME(equal) // OK: not using `operator==`.
  24. point a; a.x = 1; a.y = 2;
  25. point b = a;
  26. BOOST_TEST(equal(a, b));
  27. return boost::report_errors();
  28. }
  29. //]
  30. #endif // VARIADIC_MACROS