Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
alib2std
src
extensions
utility.hpp
Go to the documentation of this file.
1
6
/*
7
* This file is part of Algorithms library toolkit.
8
* Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
9
10
* Algorithms library toolkit is free software: you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation, either version 3 of the License, or
13
* (at your option) any later version.
14
15
* Algorithms library toolkit is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
19
20
* You should have received a copy of the GNU General Public License
21
* along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>.
22
*/
23
24
#pragma once
25
26
#include <utility>
27
28
#include "
type_traits.hpp
"
29
30
#include <
extensions/container/ptr_value.hpp
>
31
32
namespace
ext
{
33
44
template
<
class
T >
45
inline
auto
move_copy
(
const
T & param ) {
46
if
constexpr
(
ext::has_clone < T >::value
&& ! std::is_final_v < T > ) {
47
return
ptr_value < T >
( param );
48
}
else
{
49
return
T ( param );
50
}
51
}
52
53
namespace
detail {
54
55
template
<
class
F, std::size_t ... Is >
56
void
constexpr_switch
(
const
std::size_t
i
, F && f, std::index_sequence < Is ... > ) {
57
[ ] ( ... ) { } (
58
(
i
== Is && ( ( void ) std::forward < F > ( f ) . operator ( ) ( std::integral_constant < size_t, Is > ( ) ),
false
) ) ...
59
);
60
}
61
62
}
// namespace detail
63
64
template
< std::
size_t
N,
class
F >
65
void
constexpr_switch
(
const
std::size_t
i
, F && f ) {
66
detail::constexpr_switch
(
i
, std::forward < F > ( f ), std::make_index_sequence < N > { } );
67
}
68
69
}
/* namespace ext */
70
ext::ptr_value
Class representing wrapper of dynamically allocated object behaving like rvalue reference.
Definition:
ptr_value.hpp:40
automaton::properties::i
int i
Definition:
AllEpsilonClosure.h:118
ext::detail::constexpr_switch
void constexpr_switch(const std::size_t i, F &&f, std::index_sequence< Is ... >)
Definition:
utility.hpp:56
ext
Definition:
sigHandler.cpp:20
ext::constexpr_switch
void constexpr_switch(const std::size_t i, F &&f)
Definition:
utility.hpp:65
ext::move_copy
auto move_copy(const T ¶m)
Allow moving of copied instance of the source.
Definition:
utility.hpp:45
ptr_value.hpp
ext::has_clone
Type trait to determine existence of clone method. A boolean field namd value is set to true if provi...
Definition:
type_traits.hpp:39
type_traits.hpp
Generated on Mon Dec 27 2021 10:21:54 for Algorithms Library Toolkit by
1.9.2