identity.hpp 844 B

1234567891011121314151617181920212223242526272829
  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/functional/overloaded_function
  6. #ifndef IDENTITY_HPP_
  7. #define IDENTITY_HPP_
  8. //[identity_typeof
  9. #include <boost/typeof/std/string.hpp> // No need to register `boost::function`.
  10. //]
  11. #include <boost/function.hpp>
  12. #include <string>
  13. //[identity_decls
  14. const std::string& identity_s(const std::string& x) // Function (as pointer).
  15. { return x; }
  16. int identity_i_impl(int x) { return x; }
  17. int (&identity_i)(int) = identity_i_impl; // Function reference.
  18. double identity_d_impl(double x) { return x; }
  19. boost::function<double (double)> identity_d = identity_d_impl; // Functor.
  20. //]
  21. #endif // #include guard