Maxim Integrated / Mbed OS MAXREFDES155#

Dependencies:   MaximInterface

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers swap.h Source File

swap.h

00001 // Tencent is pleased to support the open source community by making RapidJSON available.
00002 //
00003 // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.
00004 //
00005 // Licensed under the MIT License (the "License"); you may not use this file except
00006 // in compliance with the License. You may obtain a copy of the License at
00007 //
00008 // http://opensource.org/licenses/MIT
00009 //
00010 // Unless required by applicable law or agreed to in writing, software distributed
00011 // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
00012 // CONDITIONS OF ANY KIND, either express or implied. See the License for the
00013 // specific language governing permissions and limitations under the License.
00014 
00015 #ifndef RAPIDJSON_INTERNAL_SWAP_H_
00016 #define RAPIDJSON_INTERNAL_SWAP_H_
00017 
00018 #include "../rapidjson.h"
00019 
00020 #if defined(__clang__)
00021 RAPIDJSON_DIAG_PUSH
00022 RAPIDJSON_DIAG_OFF(c++98-compat)
00023 #endif
00024 
00025 RAPIDJSON_NAMESPACE_BEGIN
00026 namespace internal {
00027 
00028 //! Custom swap() to avoid dependency on C++ <algorithm> header
00029 /*! \tparam T Type of the arguments to swap, should be instantiated with primitive C++ types only.
00030     \note This has the same semantics as std::swap().
00031 */
00032 template <typename T>
00033 inline void Swap(T& a, T& b) RAPIDJSON_NOEXCEPT {
00034     T tmp = a;
00035         a = b;
00036         b = tmp;
00037 }
00038 
00039 } // namespace internal
00040 RAPIDJSON_NAMESPACE_END
00041 
00042 #if defined(__clang__)
00043 RAPIDJSON_DIAG_POP
00044 #endif
00045 
00046 #endif // RAPIDJSON_INTERNAL_SWAP_H_