detail/optional.hpp
Go to the documentation of this file.
1 // Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 #ifndef _FASTCDR_XCDR_DETAIL_OPTIONAL_HPP_
16 #define _FASTCDR_XCDR_DETAIL_OPTIONAL_HPP_
17 
18 #include <type_traits>
19 
20 namespace eprosima {
21 namespace fastcdr {
22 namespace detail {
23 template<class T, typename = void>
25 {
26  union
27  {
28  char dummy_;
29  T val_;
30  };
31 
32  bool engaged_ { false };
33 
35  {
36  }
37 
39  {
40  if (engaged_)
41  {
42  val_.~T();
43  }
44  }
45 
46 };
47 
48 /* *INDENT-OFF* */
49 template<class T>
50 struct optional_storage<T, typename std::enable_if<std::is_trivially_destructible<T>{}>::type>
51 {
52  union
53  {
54  char dummy_; T val_;
55  };
56 
57  bool engaged_ { false };
58 
60  {
61  }
62 
63  ~optional_storage() = default;
64 };
65 /* *INDENT-ON* */
66 } // namespace detail
67 } // namespace fastcdr
68 } // namespace eprosima
69 
70 #endif //_FASTCDR_XCDR_DETAIL_OPTIONAL_HPP_
71 
backward::ColorMode::type
type
Definition: backward.hpp:3600
eprosima::fastcdr::detail::optional_storage< T, typename std::enable_if< std::is_trivially_destructible< T >{}>::type >::val_
T val_
Definition: detail/optional.hpp:54
eprosima::fastcdr::detail::optional_storage::engaged_
bool engaged_
Definition: detail/optional.hpp:32
detail
Definition: args.h:19
eprosima::fastcdr::detail::optional_storage
Definition: detail/optional.hpp:24
eprosima::fastcdr::detail::optional_storage::val_
T val_
Definition: detail/optional.hpp:29
eprosima::fastcdr::detail::optional_storage::optional_storage
optional_storage()
Definition: detail/optional.hpp:34
eprosima::fastcdr::detail::optional_storage::dummy_
char dummy_
Definition: detail/optional.hpp:28
eprosima::fastcdr::detail::optional_storage::~optional_storage
~optional_storage()
Definition: detail/optional.hpp:38
std
eprosima::fastcdr::detail::optional_storage< T, typename std::enable_if< std::is_trivially_destructible< T >{}>::type >::optional_storage
optional_storage()
Definition: detail/optional.hpp:59
eprosima
Definition: fixed_size_string.hpp:32


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:45