Coverage Report

Created: 2023-03-26 06:57

/src/boost/boost/json/impl/visit.hpp
Line
Count
Source (jump to first uncovered line)
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
10
#ifndef BOOST_JSON_IMPL_VISIT_HPP
11
#define BOOST_JSON_IMPL_VISIT_HPP
12
13
namespace boost {
14
namespace json {
15
16
template<class Visitor>
17
auto
18
visit(
19
    Visitor&& v,
20
    value& jv) -> decltype(
21
        std::declval<Visitor>()(nullptr))
22
{
23
    switch(jv.kind())
24
    {
25
    default: // unreachable()?
26
    case kind::null:    return std::forward<Visitor>(v)(nullptr);
27
    case kind::bool_:   return std::forward<Visitor>(v)(jv.get_bool());
28
    case kind::int64:   return std::forward<Visitor>(v)(jv.get_int64());
29
    case kind::uint64:  return std::forward<Visitor>(v)(jv.get_uint64());
30
    case kind::double_: return std::forward<Visitor>(v)(jv.get_double());
31
    case kind::string:  return std::forward<Visitor>(v)(jv.get_string());
32
    case kind::array:   return std::forward<Visitor>(v)(jv.get_array());
33
    case kind::object:  return std::forward<Visitor>(v)(jv.get_object());
34
    }
35
}
36
37
template<class Visitor>
38
auto
39
visit(
40
    Visitor&& v,
41
    value const& jv) -> decltype(
42
        std::declval<Visitor>()(nullptr))
43
0
{
44
0
    switch (jv.kind())
45
0
    {
46
0
    default: // unreachable()?
47
0
    case kind::null:    return std::forward<Visitor>(v)(nullptr);
48
0
    case kind::bool_:   return std::forward<Visitor>(v)(jv.get_bool());
49
0
    case kind::int64:   return std::forward<Visitor>(v)(jv.get_int64());
50
0
    case kind::uint64:  return std::forward<Visitor>(v)(jv.get_uint64());
51
0
    case kind::double_: return std::forward<Visitor>(v)(jv.get_double());
52
0
    case kind::string:  return std::forward<Visitor>(v)(jv.get_string());
53
0
    case kind::array:   return std::forward<Visitor>(v)(jv.get_array());
54
0
    case kind::object:  return std::forward<Visitor>(v)(jv.get_object());
55
0
    }
56
0
}
57
58
} // namespace json
59
} // namespace boost
60
61
#endif