visit.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
  3. //
  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. // Official repository: https://github.com/boostorg/json
  8. //
  9. #ifndef BOOST_JSON_VISIT_HPP
  10. #define BOOST_JSON_VISIT_HPP
  11. #include <boost/json/detail/config.hpp>
  12. #include <boost/json/value.hpp>
  13. #include <type_traits>
  14. #include <utility>
  15. namespace boost {
  16. namespace json {
  17. /** Invoke a function object with the contents of a @ref value
  18. @return The value returned by Visitor.
  19. @param v The visitation function to invoke
  20. @param jv The value to visit.
  21. */
  22. /** @{ */
  23. template<class Visitor>
  24. auto
  25. visit(
  26. Visitor&& v,
  27. value& jv) -> decltype(
  28. std::declval<Visitor>()(nullptr));
  29. template<class Visitor>
  30. auto
  31. visit(
  32. Visitor &&v,
  33. value const &jv) -> decltype(
  34. std::declval<Visitor>()(nullptr));
  35. /** @} */
  36. } // namespace json
  37. } // namespace boost
  38. #include <boost/json/impl/visit.hpp>
  39. #endif