swap.h

Engine/source/persistence/rapidjson/internal/swap.h

More...

Namespaces:

namespace

Detailed Description

 1
 2// Tencent is pleased to support the open source community by making RapidJSON available.
 3//
 4// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
 5//
 6// Licensed under the MIT License (the "License"); you may not use this file except
 7// in compliance with the License. You may obtain a copy of the License at
 8//
 9// http://opensource.org/licenses/MIT
10//
11// Unless required by applicable law or agreed to in writing, software distributed
12// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
13// CONDITIONS OF ANY KIND, either express or implied. See the License for the
14// specific language governing permissions and limitations under the License.
15
16#ifndef RAPIDJSON_INTERNAL_SWAP_H_
17#define RAPIDJSON_INTERNAL_SWAP_H_
18
19#include "../rapidjson.h"
20
21#if defined(__clang__)
22RAPIDJSON_DIAG_PUSH
23RAPIDJSON_DIAG_OFF(c++98-compat)
24#endif
25
26RAPIDJSON_NAMESPACE_BEGIN
27namespace internal {
28
29//! Custom swap() to avoid dependency on C++ <algorithm> header
30/*! \tparam T Type of the arguments to swap, should be instantiated with primitive C++ types only.
31    \note This has the same semantics as std::swap().
32*/
33template <typename T>
34inline void Swap(T& a, T& b) RAPIDJSON_NOEXCEPT {
35    T tmp = a;
36        a = b;
37        b = tmp;
38}
39
40} // namespace internal
41RAPIDJSON_NAMESPACE_END
42
43#if defined(__clang__)
44RAPIDJSON_DIAG_POP
45#endif
46
47#endif // RAPIDJSON_INTERNAL_SWAP_H_
48