pjmsg_mcap_wrapper
Loading...
Searching...
No Matches
src
3rdparty
fastcdr
include
fastcdr
xcdr
detail
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
>
24
struct
optional_storage
25
{
26
union
27
{
28
char
dummy_
;
29
T
val_
;
30
};
31
32
bool
engaged_
{
false
};
33
34
optional_storage
()
35
{
36
}
37
38
~optional_storage
()
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>::value>::type>
51
{
52
union
53
{
54
char
dummy_
; T
val_
;
55
};
56
57
bool
engaged_
{
false
};
58
59
optional_storage
()
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
eprosima
Definition
Cdr.h:49
std
eprosima::fastcdr::detail::optional_storage< T, typename std::enable_if< std::is_trivially_destructible< T >::value >::type >::~optional_storage
~optional_storage()=default
eprosima::fastcdr::detail::optional_storage< T, typename std::enable_if< std::is_trivially_destructible< T >::value >::type >::optional_storage
optional_storage()
Definition
detail/optional.hpp:59
eprosima::fastcdr::detail::optional_storage< T, typename std::enable_if< std::is_trivially_destructible< T >::value >::type >::dummy_
char dummy_
Definition
detail/optional.hpp:54
eprosima::fastcdr::detail::optional_storage
Definition
detail/optional.hpp:25
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:38
eprosima::fastcdr::detail::optional_storage::optional_storage
optional_storage()
Definition
detail/optional.hpp:34
eprosima::fastcdr::detail::optional_storage::engaged_
bool engaged_
Definition
detail/optional.hpp:32
eprosima::fastcdr::detail::optional_storage::dummy_
char dummy_
Definition
detail/optional.hpp:28
type_traits
Generated by
1.9.8