VCCC  2024.05
VisualCamp Common C++ library
copy_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_COPY_CTOR_H_
6 # define VCCC_OPTIONAL_INTERNAL_COPY_CTOR_H_
7 #
8 # include <type_traits>
9 #
11 
12 namespace vccc {
13 namespace internal {
14 namespace optional {
15 
17 struct copy_ctor : dtor<T> {
18  using base = dtor<T>;
19  using base::base;
20 };
21 
22 template<typename T>
23 struct copy_ctor<T, false> : dtor<T> {
24  using base = dtor<T>;
25  using base::base;
26 
27  copy_ctor() = default;
28  copy_ctor(copy_ctor const& other) {
29  if (other.valid) {
30  this->construct(other.val);
31  }
32  }
33  copy_ctor(copy_ctor &&) = default;
34  copy_ctor& operator=(copy_ctor const&) = default;
35  copy_ctor& operator=(copy_ctor &&) = default;
36 };
37 
38 } // namespace optional
39 } // namespace internal
40 } // namespace vccc
41 
42 
43 # endif // VCCC_OPTIONAL_INTERNAL_COPY_CTOR_H_
Definition: directory.h:12
constexpr VCCC_INLINE_OR_STATIC detail::element_niebloid< 1 > value
Definition: key_value.hpp:35