ALFI
Advanced Library for Function Interpolation
Main Page
Namespaces
Classes
Files
File List
File Members
Loading...
Searching...
No Matches
misc.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <algorithm>
4
#include <utility>
5
6
namespace
alfi::util::misc
{
7
template
<
typename
Function>
8
class
SimpleScopeGuard
{
9
public
:
10
// ReSharper disable once CppNonExplicitConvertingConstructor
11
SimpleScopeGuard
(Function on_exit) : _on_exit(std::move(on_exit)) {}
// NOLINT(*-explicit-constructor)
12
~SimpleScopeGuard
() noexcept { _on_exit(); }
13
SimpleScopeGuard
(
const
SimpleScopeGuard
&) =
delete
;
14
SimpleScopeGuard
&
operator=
(
const
SimpleScopeGuard
&) =
delete
;
15
private
:
16
Function _on_exit;
17
};
18
19
template
<
typename
... Ts>
20
struct
overload
: Ts... {
21
using
Ts::operator()...;
22
};
23
template
<
typename
... Ts>
24
overload
(Ts...) ->
overload
<Ts...>;
25
26
template
<
typename
Iterator,
typename
T>
27
Iterator
first_leq_or_begin
(Iterator begin, Iterator end,
const
T& value) {
28
auto
iter = std::lower_bound(begin, end - 1, value);
29
if
(iter != begin && *iter > value) {
30
--iter;
31
}
32
return
iter;
33
}
34
}
alfi::util::misc::SimpleScopeGuard::SimpleScopeGuard
SimpleScopeGuard(Function on_exit)
Definition
misc.h:11
alfi::util::misc::SimpleScopeGuard::~SimpleScopeGuard
~SimpleScopeGuard() noexcept
Definition
misc.h:12
alfi::util::misc::SimpleScopeGuard::SimpleScopeGuard
SimpleScopeGuard(const SimpleScopeGuard &)=delete
alfi::util::misc::SimpleScopeGuard::operator=
SimpleScopeGuard & operator=(const SimpleScopeGuard &)=delete
alfi::util::misc
Definition
misc.h:6
alfi::util::misc::first_leq_or_begin
Iterator first_leq_or_begin(Iterator begin, Iterator end, const T &value)
Definition
misc.h:27
alfi::util::misc::overload
overload(Ts...) -> overload< Ts... >
alfi::util::misc::overload
Definition
misc.h:20
ALFI
ALFI
util
misc.h
Generated by
1.13.2