OpenShot Audio Library | OpenShotAudio
1.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
juce_Functional.h
1
/*
2
==============================================================================
3
4
This file is part of the JUCE library.
5
Copyright (c) 2022 - Raw Material Software Limited
6
7
JUCE is an open source library subject to commercial or open-source
8
licensing.
9
10
The code included in this file is provided under the terms of the ISC license
11
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12
To use, copy, modify, and/or distribute this software for any purpose with or
13
without fee is hereby granted provided that the above copyright notice and
14
this permission notice appear in all copies.
15
16
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18
DISCLAIMED.
19
20
==============================================================================
21
*/
22
23
namespace
juce
24
{
25
26
#ifndef DOXYGEN
27
namespace
detail
28
{
29
template
<
typename
...>
30
using
Void = void;
31
32
template
<
typename
,
typename
=
void
>
33
constexpr
auto
equalityComparableToNullptr =
false
;
34
35
template
<
typename
T>
36
constexpr
auto
equalityComparableToNullptr<T, Void<decltype (std::declval<T>() !=
nullptr
)>> =
true
;
37
}
// namespace detail
38
#endif
39
40
//==============================================================================
49
struct
NullCheckedInvocation
50
{
51
template
<
typename
Callable,
typename
... Args>
52
static
void
invoke (Callable&& fn, Args&&... args)
53
{
54
if
constexpr
(detail::equalityComparableToNullptr<Callable>)
55
{
56
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE (
"-Waddress"
)
57
58
if
(fn !=
nullptr
)
59
fn (std::forward<Args> (args)...);
60
61
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
62
}
63
else
64
{
65
fn (std::forward<Args> (args)...);
66
}
67
}
68
69
template
<
typename
... Args>
70
static
void
invoke (std::nullptr_t, Args&&...) {}
71
};
72
78
template
<
typename
A,
typename
B>
79
using
DisableIfSameOrDerived = std::enable_if_t<! std::is_base_of_v<A, std::remove_reference_t<B>>>;
80
82
template
<
typename
Object,
typename
OtherObject,
typename
Member,
typename
Other>
83
[[nodiscard]] Object withMember (Object copy, Member OtherObject::* member, Other&& value)
84
{
85
copy.*member = std::forward<Other> (value);
86
return
copy;
87
}
88
89
#ifndef DOXYGEN
90
namespace
detail
91
{
92
template
<
typename
Functor,
typename
Return,
typename
... Args>
93
static
constexpr
auto
toFnPtr (Functor functor, Return (Functor::*) (Args...)
const
)
94
{
95
return
static_cast<
Return (*) (Args...)
>
(functor);
96
}
97
}
// namespace detail
98
#endif
99
101
template
<
typename
Functor>
102
static
constexpr
auto
toFnPtr (Functor functor) {
return
detail::toFnPtr (functor, &Functor::operator()); }
103
104
}
// namespace juce
juce::NullCheckedInvocation
Definition
juce_Functional.h:50
libopenshot-audio
JuceLibraryCode
modules
juce_core
misc
juce_Functional.h
Generated by
1.18.0