My Project
exchange.hpp
Go to the documentation of this file.
1 
28 #ifndef BSL_EXCHANGE_HPP
29 #define BSL_EXCHANGE_HPP
30 
31 #include "forward.hpp"
32 #include "move.hpp"
33 
34 namespace bsl
35 {
52  template<typename T, typename U = T>
53  constexpr T
54  exchange(T &obj, U &&new_value) noexcept(false)
55  {
56  T const old_value{bsl::move(obj)};
57  obj = bsl::forward<U>(new_value);
58  return old_value;
59  }
60 
61 }
62 
63 #endif
constexpr T exchange(T &obj, U &&new_value) noexcept(false)
Replaces the value of obj with new_value and returns the old value of obj.
Definition: exchange.hpp:54
constexpr void move(fmt< V > &&val) noexcept=delete
Used to prevent a move of bsl::fmt as it must always be a temporary r-value.