Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dumux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dumux-repositories
dumux
Commits
b43580dd
Commit
b43580dd
authored
4 years ago
by
Timo Koch
Browse files
Options
Downloads
Patches
Plain Diff
[cleanup] Remove optional.hh
parent
9b753c4a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1968
Feature/remove deprecated
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dumux/common/CMakeLists.txt
+0
-1
0 additions, 1 deletion
dumux/common/CMakeLists.txt
dumux/common/optional.hh
+0
-154
0 additions, 154 deletions
dumux/common/optional.hh
with
0 additions
and
155 deletions
dumux/common/CMakeLists.txt
+
0
−
1
View file @
b43580dd
...
...
@@ -26,7 +26,6 @@ loggingparametertree.hh
math.hh
monotonecubicspline.hh
numericdifferentiation.hh
optional.hh
parameters.hh
partial.hh
pdesolver.hh
...
...
This diff is collapsed.
Click to expand it.
dumux/common/optional.hh
deleted
100644 → 0
+
0
−
154
View file @
9b753c4a
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
* \ingroup Common
* \brief A wrapper that can either contain an object of T or be empty.
* This might be used as a workaround for non-default constructible classes.
* \note Replace this with std::optional when C++17 is available
*/
#ifndef DUMUX_COMMON_OPTIONAL_HH
#define DUMUX_COMMON_OPTIONAL_HH
#warning "This header is deprecated and will be removed after release 3.2"
#include
<utility>
#include
<dune/common/typeutilities.hh>
namespace
Dumux
{
/*!
* \ingroup Common
* \brief A wrapper that can either contain an object of T or be empty
* \tparam T Type of wrapped objects
*/
template
<
class
T
>
class
[[
deprecated
(
"Optional is deprecated (removed after 3.2); use std::optional"
)]]
Optional
{
public:
Optional
()
:
p_
(
nullptr
)
{}
template
<
class
TT
,
Dune
::
disableCopyMove
<
Optional
,
TT
>
=
0
>
Optional
(
TT
&&
t
)
:
p_
(
nullptr
)
{
emplace
(
std
::
forward
<
TT
>
(
t
));
}
Optional
(
Optional
&&
other
)
{
if
(
other
)
p_
=
new
(
buffer_
)
T
(
std
::
move
(
other
.
value
()));
else
p_
=
nullptr
;
}
Optional
(
const
Optional
&
other
)
{
if
(
other
)
p_
=
new
(
buffer_
)
T
(
other
.
value
());
else
p_
=
nullptr
;
}
~
Optional
()
{
if
(
operator
bool
())
p_
->~
T
();
}
template
<
class
TT
,
Dune
::
disableCopyMove
<
Optional
,
TT
>
=
0
>
Optional
&
operator
=
(
TT
&&
t
)
{
if
(
operator
bool
())
*
p_
=
std
::
forward
<
T
>
(
t
);
else
p_
=
new
(
buffer_
)
T
(
std
::
forward
<
T
>
(
t
));
return
*
this
;
}
Optional
&
operator
=
(
const
Optional
&
other
)
{
if
(
other
)
*
this
=
other
.
value
();
else
if
(
operator
bool
())
{
p_
->~
T
();
p_
=
nullptr
;
}
return
*
this
;
}
Optional
&
operator
=
(
Optional
&&
other
)
{
if
(
other
)
*
this
=
std
::
move
(
other
.
value
());
else
if
(
operator
bool
())
{
p_
->~
T
();
p_
=
nullptr
;
}
return
*
this
;
}
explicit
operator
bool
()
const
{
return
p_
;
}
const
T
&
value
()
const
{
return
*
p_
;
}
T
&
value
()
{
return
*
p_
;
}
template
<
class
...
Args
>
void
emplace
(
Args
&&
...
args
)
{
if
(
operator
bool
())
p_
->~
T
();
p_
=
new
(
buffer_
)
T
(
std
::
forward
<
Args
>
(
args
)...);
}
void
release
()
{
if
(
operator
bool
())
{
p_
->~
T
();
p_
=
nullptr
;
}
}
private
:
alignas
(
T
)
char
buffer_
[
sizeof
(
T
)];
T
*
p_
;
};
}
// namespace Dumux
#endif // DUMUX_COMMON_OPTIONAL_HH
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment