Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F116539
std-optional.hpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
std-optional.hpp
View Options
/*
* This file is part of libkazv.
* SPDX-FileCopyrightText: 2021 Tusooa Zhu <tusooa@kazv.moe>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#pragma once
#include
<libkazv-config.hpp>
#include
<boost/serialization/nvp.hpp>
#include
<boost/serialization/split_free.hpp>
#include
<optional>
namespace
boost
::
serialization
{
template
<
class
Archive
,
class
T
>
void
save
(
Archive
&
ar
,
const
std
::
optional
<
T
>
&
o
,
const
unsigned
int
/* version */
)
{
auto
hasValue
=
o
.
has_value
();
ar
<<
BOOST_SERIALIZATION_NVP
(
hasValue
);
if
(
hasValue
)
{
const
auto
&
value
=
o
.
value
();
ar
<<
BOOST_SERIALIZATION_NVP
(
value
);
}
}
template
<
class
Archive
,
class
T
>
void
load
(
Archive
&
ar
,
std
::
optional
<
T
>
&
o
,
const
unsigned
int
/* version */
)
{
auto
hasValue
=
bool
{};
ar
>>
BOOST_SERIALIZATION_NVP
(
hasValue
);
o
.
reset
();
if
(
hasValue
)
{
T
value
;
ar
>>
BOOST_SERIALIZATION_NVP
(
value
);
o
=
std
::
move
(
value
);
}
}
template
<
class
Archive
,
class
T
>
inline
void
serialize
(
Archive
&
ar
,
std
::
optional
<
T
>
&
o
,
const
unsigned
int
version
)
{
boost
::
serialization
::
split_free
(
ar
,
o
,
version
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Sun, Dec 1, 6:40 PM (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41797
Default Alt Text
std-optional.hpp (1 KB)
Attached To
Mode
rL libkazv
Attached
Detach File
Event Timeline
Log In to Comment