Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers _move.h Source File

_move.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2019 ARM Limited
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 #ifndef __move_h
00018 #define __move_h
00019 
00020 namespace std
00021 {
00022 template <typename T>
00023 struct remove_reference { using type = T; };
00024 
00025 template <typename T>
00026 struct remove_reference<T &> { using type = T; };
00027 
00028 template <typename T>
00029 struct remove_reference<T &&> { using type = T; };
00030 
00031 template <typename T>
00032 using remove_reference_t = typename remove_reference<T>::type;
00033 
00034 // Note that these implementations do not function as
00035 // constant expressions in ARM C 5, so are not marked constexpr.
00036 // This makes them C++11 compliant, but not C++14.
00037 
00038 // [forward]
00039 template <typename _TypeT>
00040 _TypeT &&forward(remove_reference_t<_TypeT> &__t) noexcept
00041 {
00042     return static_cast<_TypeT &&>(__t);
00043 }
00044 
00045 template <typename _TypeT>
00046 _TypeT &&forward(remove_reference_t<_TypeT> &&__t) noexcept
00047 {
00048     return static_cast<_TypeT &&>(__t);
00049 }
00050 
00051 template <typename _TypeT>
00052 remove_reference_t<_TypeT> &&move(_TypeT &&__t) noexcept
00053 {
00054     return static_cast<remove_reference_t<_TypeT> &&>(__t);
00055 }
00056 
00057 // [utility.exchange]
00058 template <typename _TypeT, typename _TypeU = _TypeT>
00059 _TypeT exchange(_TypeT &__obj, _TypeU &&__new_val)
00060 {
00061     _TypeT __old_val = std::move(__obj);
00062     __obj = std::forward<_TypeU>(__new_val);
00063     return __old_val;
00064 }
00065 
00066 } // namespace std
00067 
00068 #endif /* __move_h */