LMMS
Loading...
Searching...
No Matches
juce_Functional.h
Go to the documentation of this file.
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
23namespace juce
24{
25
26#ifndef DOXYGEN
27namespace detail
28{
29 template <typename...>
30 using Void = void;
31
32 template <typename, typename = void>
34 : std::false_type {};
35
36 template <typename T>
38 : std::true_type {};
39
40 template <typename T>
42} // namespace detail
43#endif
44
45//==============================================================================
55{
56 template <typename Callable, typename... Args,
57 std::enable_if_t<detail::shouldCheckAgainstNullptr<Callable>, int> = 0>
58 static void invoke (Callable&& fn, Args&&... args)
59 {
61
62 if (fn != nullptr)
63 fn (std::forward<Args> (args)...);
64
66 }
67
68 template <typename Callable, typename... Args,
69 std::enable_if_t<! detail::shouldCheckAgainstNullptr<Callable>, int> = 0>
70 static void invoke (Callable&& fn, Args&&... args)
71 {
72 fn (std::forward<Args> (args)...);
73 }
74
75 template <typename... Args>
76 static void invoke (std::nullptr_t, Args&&...) {}
77};
78
84template <typename A, typename B>
85using DisableIfSameOrDerived = typename std::enable_if_t<! std::is_base_of<A, std::remove_reference_t<B>>::value>;
86
88template <typename Object, typename OtherObject, typename Member>
89Object withMember (Object copy, Member OtherObject::* member, Member&& value)
90{
91 copy.*member = std::forward<Member> (value);
92 return copy;
93}
94
95} // namespace juce
#define copy(x)
Definition ADnoteParameters.cpp:1011
static PuglViewHint int value
Definition pugl.h:1708
#define JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE(...)
Definition juce_CompilerWarnings.h:181
#define JUCE_END_IGNORE_WARNINGS_GCC_LIKE
Definition juce_CompilerWarnings.h:182
Definition juce_FloatVectorOperations.h:143
constexpr bool shouldCheckAgainstNullptr
Definition juce_Functional.h:41
void Void
Definition juce_Functional.h:30
Definition carla_juce.cpp:31
Object withMember(Object copy, Member OtherObject::*member, Member &&value)
Definition juce_Functional.h:89
typename std::enable_if_t<! std::is_base_of< A, std::remove_reference_t< B > >::value > DisableIfSameOrDerived
Definition juce_Functional.h:85
Definition juce_Uuid.h:141
Definition juce_Functional.h:55
static void invoke(std::nullptr_t, Args &&...)
Definition juce_Functional.h:76
static void invoke(Callable &&fn, Args &&... args)
Definition juce_Functional.h:58
Definition juce_Functional.h:34
const char const char const char const char char * fn
Definition swell-functions.h:168
#define void
Definition unzip.h:396