DotNetDupe
4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Toggle main menu visibility
Loading...
Searching...
No Matches
Predicate.h
Go to the documentation of this file.
1
5
6
#pragma once
7
#include "
System/Func.h
"
8
#include <type_traits>
9
10
namespace
DotNetDupe
{
11
namespace
System
{
18
template
<
typename
T>
19
class
Predicate
{
20
public
:
22
Predicate
() : m_func() {}
23
25
Predicate
(
decltype
(
nullptr
)) : m_func(nullptr) {}
26
30
template
<
typename
F,
typename
= std::enable_if_t<!std::is_same_v<std::decay_t<F>, Predicate> && std::is_invocable_r_v<
bool
, std::decay_t<F>, T>>>
31
Predicate
(F&& func) : m_func(static_cast<F&&>(func)) {}
32
36
bool
Invoke
(T obj)
const
{
37
return
m_func ? m_func.Invoke(obj) :
false
;
38
}
39
43
bool
operator()
(T obj)
const
{
44
return
Invoke
(obj);
45
}
46
49
explicit
operator
bool()
const
{
return
static_cast<
bool
>
(m_func); }
50
51
private
:
52
Func<bool, T>
m_func;
53
};
54
}
55
}
Func.h
Encapsulates a method that has parameters and returns a value of the type specified by the TResult pa...
DotNetDupe::System::Func
Primary template declaration for the Func delegate family.
Definition
Func.h:42
DotNetDupe::System::Predicate::Predicate
Predicate()
Initializes an empty instance of the Predicate class.
Definition
Predicate.h:22
DotNetDupe::System::Predicate::Predicate
Predicate(decltype(nullptr))
Initializes an empty instance from a null pointer.
Definition
Predicate.h:25
DotNetDupe::System::Predicate::Invoke
bool Invoke(T obj) const
Evaluates the predicate criteria against the provided object.
Definition
Predicate.h:36
DotNetDupe::System::Predicate::Predicate
Predicate(F &&func)
Constructs a Predicate delegate from a callable object or lambda.
Definition
Predicate.h:31
DotNetDupe::System::Predicate::operator()
bool operator()(T obj) const
Function call operator forwarding to Invoke().
Definition
Predicate.h:43
DotNetDupe::System
Definition
Action.h:11
DotNetDupe
Definition
IServiceCollection.h:7
Include
System
Predicate.h
Generated by
1.18.0