VCCC  2024.05
VisualCamp Common C++ library
move_ctor.h
Go to the documentation of this file.
1 # /*
2 # * Created by YongGyu Lee on 2021/05/24.
3 # */
4 #
5 # ifndef VCCC_OPTIONAL_INTERNAL_MOVE_CTOR_H_
6 # define VCCC_OPTIONAL_INTERNAL_MOVE_CTOR_H_
7 #
8 # include <type_traits>
9 #
11 
12 namespace vccc {
13 namespace internal {
14 namespace optional {
15 
17 struct move_ctor : copy_ctor<T> {
18  using base = copy_ctor<T>;
19  using base::base;
20 };
21 
22 template<typename T>
23 struct move_ctor<T, false> : copy_ctor<T> {
24  using base = copy_ctor<T>;
25  using base::base;
26 
27  move_ctor() = default;
28  move_ctor(move_ctor const&) = default;
29  move_ctor(move_ctor && other) noexcept(std::is_nothrow_move_constructible<T>::value) {
30  if (other.valid) {
31  this->construct(std::move(other.val));
32  }
33  }
34  move_ctor& operator=(move_ctor const&) = default;
35  move_ctor& operator=(move_ctor &&) = default;
36 };
37 
38 } // namespace optional
39 } // namespace internal
40 } // namespace vccc
41 
42 
43 # endif // VCCC_OPTIONAL_INTERNAL_MOVE_CTOR_H_
Definition: directory.h:12
constexpr VCCC_INLINE_OR_STATIC detail::element_niebloid< 1 > value
Definition: key_value.hpp:35