Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:39:03

0001 //
0002 // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // Official repository: https://github.com/boostorg/json
0008 //
0009 
0010 #ifndef BOOST_JSON_IMPL_VISIT_HPP
0011 #define BOOST_JSON_IMPL_VISIT_HPP
0012 
0013 namespace boost {
0014 namespace json {
0015 
0016 template<class Visitor>
0017 auto
0018 visit(
0019     Visitor&& v,
0020     value& jv) -> decltype(
0021         std::declval<Visitor>()(nullptr))
0022 {
0023     switch(jv.kind())
0024     {
0025     default: // unreachable()?
0026     case kind::null:    return std::forward<Visitor>(v)(nullptr);
0027     case kind::bool_:   return std::forward<Visitor>(v)(jv.get_bool());
0028     case kind::int64:   return std::forward<Visitor>(v)(jv.get_int64());
0029     case kind::uint64:  return std::forward<Visitor>(v)(jv.get_uint64());
0030     case kind::double_: return std::forward<Visitor>(v)(jv.get_double());
0031     case kind::string:  return std::forward<Visitor>(v)(jv.get_string());
0032     case kind::array:   return std::forward<Visitor>(v)(jv.get_array());
0033     case kind::object:  return std::forward<Visitor>(v)(jv.get_object());
0034     }
0035 }
0036 
0037 template<class Visitor>
0038 auto
0039 visit(
0040     Visitor&& v,
0041     value const& jv) -> decltype(
0042         std::declval<Visitor>()(nullptr))
0043 {
0044     switch (jv.kind())
0045     {
0046     default: // unreachable()?
0047     case kind::null:    return std::forward<Visitor>(v)(nullptr);
0048     case kind::bool_:   return std::forward<Visitor>(v)(jv.get_bool());
0049     case kind::int64:   return std::forward<Visitor>(v)(jv.get_int64());
0050     case kind::uint64:  return std::forward<Visitor>(v)(jv.get_uint64());
0051     case kind::double_: return std::forward<Visitor>(v)(jv.get_double());
0052     case kind::string:  return std::forward<Visitor>(v)(jv.get_string());
0053     case kind::array:   return std::forward<Visitor>(v)(jv.get_array());
0054     case kind::object:  return std::forward<Visitor>(v)(jv.get_object());
0055     }
0056 }
0057 
0058 } // namespace json
0059 } // namespace boost
0060 
0061 #endif