Skip to content

Commit 991ecf5

Browse files
committed
function_objects.hpp
1 parent 0122d03 commit 991ecf5

4 files changed

Lines changed: 46 additions & 29 deletions

File tree

include/jsoncons/json_visitor.hpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,10 @@
2323
#include <jsoncons/utility/bigint.hpp>
2424
#include <jsoncons/utility/byte_string.hpp>
2525
#include <jsoncons/utility/more_type_traits.hpp>
26+
#include <jsoncons/utility/function_objects.hpp>
2627

2728
namespace jsoncons {
2829

29-
struct decode_half
30-
{
31-
double operator()(uint16_t val) const
32-
{
33-
return binary::decode_half(val);
34-
}
35-
};
36-
3730
class typed_array_visitor
3831
{
3932
public:

include/jsoncons/reflect/reflect_traits_gen.hpp

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <jsoncons/semantic_tag.hpp>
2222
#include <jsoncons/ser_utils.hpp>
2323
#include <jsoncons/utility/more_type_traits.hpp>
24+
#include <jsoncons/utility/function_objects.hpp>
2425

2526
#define JSONCONS_RDONLY(X)
2627

@@ -29,24 +30,6 @@
2930
namespace jsoncons {
3031
namespace reflect {
3132

32-
struct always_true
33-
{
34-
template< typename T>
35-
constexpr bool operator()(const T&) const noexcept
36-
{
37-
return true;
38-
}
39-
};
40-
41-
struct identity
42-
{
43-
template< typename T>
44-
constexpr T&& operator()(T&& val) const noexcept
45-
{
46-
return std::forward<T>(val);
47-
}
48-
};
49-
5033
template <typename T>
5134
struct json_object_name_members
5235
{};
@@ -187,9 +170,6 @@ is_optional_value_set(const T&)
187170

188171
} // namespace reflect
189172

190-
using always_true = reflect::always_true;
191-
using identity = reflect::identity;
192-
193173
} // namespace jsoncons
194174

195175
#if defined(_MSC_VER)

include/jsoncons/typed_array.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <jsoncons/sink.hpp>
2222
#include <jsoncons/utility/bigint.hpp>
2323
#include <jsoncons/utility/conversion.hpp>
24+
#include <jsoncons/utility/function_objects.hpp>
2425

2526
namespace jsoncons {
2627

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright 2013-2026 Daniel Parker
2+
// Distributed under the Boost license, Version 1.0.
3+
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4+
5+
// See https://github.com/danielaparker/jsoncons for latest version
6+
7+
#ifndef JSONCONS_UTILITY_FUNCTION_OBJECTS_HPP
8+
#define JSONCONS_UTILITY_FUNCTION_OBJECTS_HPP
9+
10+
#include <functional>
11+
#include <jsoncons/config/compiler_support.hpp>
12+
13+
namespace jsoncons {
14+
15+
struct identity
16+
{
17+
template< typename T>
18+
constexpr T&& operator()(T&& val) const noexcept
19+
{
20+
return std::forward<T>(val);
21+
}
22+
};
23+
24+
struct always_true
25+
{
26+
template< typename T>
27+
constexpr bool operator()(const T&) const noexcept
28+
{
29+
return true;
30+
}
31+
};
32+
33+
struct decode_half
34+
{
35+
double operator()(uint16_t val) const
36+
{
37+
return binary::decode_half(val);
38+
}
39+
};
40+
41+
} // namespace jsoncons
42+
43+
#endif // JSONCONS_UTILITY_FUNCTION_OBJECTS_HPP

0 commit comments

Comments
 (0)