Mistake on this page?
Report an issue in GitHub or email us
_move.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2019 ARM Limited
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #ifndef __move_h
18 #define __move_h
19 
20 namespace std
21 {
22 template <typename T>
23 struct remove_reference { using type = T; };
24 
25 template <typename T>
26 struct remove_reference<T &> { using type = T; };
27 
28 template <typename T>
29 struct remove_reference<T &&> { using type = T; };
30 
31 template <typename T>
32 using remove_reference_t = typename remove_reference<T>::type;
33 
34 // Note that these implementations do not function as
35 // constant expressions in ARM C 5, so are not marked constexpr.
36 // This makes them C++11 compliant, but not C++14.
37 
38 // [forward]
39 template <typename _TypeT>
40 _TypeT &&forward(remove_reference_t<_TypeT> &__t) noexcept
41 {
42  return static_cast<_TypeT &&>(__t);
43 }
44 
45 template <typename _TypeT>
46 _TypeT &&forward(remove_reference_t<_TypeT> &&__t) noexcept
47 {
48  return static_cast<_TypeT &&>(__t);
49 }
50 
51 template <typename _TypeT>
52 remove_reference_t<_TypeT> &&move(_TypeT &&__t) noexcept
53 {
54  return static_cast<remove_reference_t<_TypeT> &&>(__t);
55 }
56 
57 // [utility.exchange]
58 template <typename _TypeT, typename _TypeU = _TypeT>
59 _TypeT exchange(_TypeT &__obj, _TypeU &&__new_val)
60 {
61  _TypeT __old_val = std::move(__obj);
62  __obj = std::forward<_TypeU>(__new_val);
63  return __old_val;
64 }
65 
66 } // namespace std
67 
68 #endif /* __move_h */
Definition: _move.h:20
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.