addable.hpp 669 B

1234567891011121314151617181920212223242526
  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. #ifndef ADDABLE_HPP_
  7. #define ADDABLE_HPP_
  8. #include <boost/concept_check.hpp>
  9. template<typename T>
  10. struct Addable { // User-defined concept.
  11. BOOST_CONCEPT_USAGE(Addable) {
  12. return_type(x + y); // Check addition `T operator+(T x, T y)`.
  13. }
  14. private:
  15. void return_type(T) {} // Implementation (required for some linkers).
  16. static T const& x;
  17. static T const& y;
  18. };
  19. #endif // #include guard