Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RNotFn.hxx
Go to the documentation of this file.
1/// \file ROOT/RNotFn.hxx
2/// \author Danilo Piparo, Enrico Guiraud
3/// \date 2018-01-19
4
5/*************************************************************************
6 * Copyright (C) 1995-2018, Rene Brun and Fons Rademakers. *
7 * All rights reserved. *
8 * *
9 * For the licensing terms see $ROOTSYS/LICENSE. *
10 * For the list of contributors see $ROOTSYS/README/CREDITS. *
11 *************************************************************************/
12
13#ifndef ROOT_RNotFn
14#define ROOT_RNotFn
15
16#include <functional>
17
18// Backport if not_fn is not available.
19// libc++ does not define __cpp_lib_not_fn.
20// Assume we have not_fn if libc++ is compiled with C++14 and up.
21#if !defined(__cpp_lib_not_fn) && !(defined(_LIBCPP_VERSION) && __cplusplus > 201103L)
22
23#define R__NOTFN_BACKPORT
24
25#include "ROOT/TypeTraits.hxx" // InvokeInvokeResult_t
26 //
27#include <type_traits> // std::decay
28#include <utility> // std::forward, std::declval
29
30namespace std {
31
32namespace __ROOT_noinline {
33template <typename F>
34class not_fn_t {
35 std::decay_t<F> fFun;
36
37public:
38 explicit not_fn_t(F &&f) : fFun(std::forward<F>(f)) {}
39 not_fn_t(not_fn_t &&h) = default;
40 not_fn_t(const not_fn_t &f) = default;
41
42 template <class... Args>
43 auto
44 operator()(Args &&...args) & -> decltype(!std::declval<ROOT::TypeTraits::InvokeResult_t<std::decay_t<F>, Args...>>())
45 {
46 return !fFun(std::forward<Args>(args)...);
47 }
48 template <class... Args>
49 auto operator()(Args &&...args)
50 const & -> decltype(!std::declval<ROOT::TypeTraits::InvokeResult_t<std::decay_t<F> const, Args...>>())
51 {
52 return !fFun(std::forward<Args>(args)...);
53 }
54};
55}
56
57
58template <typename F>
59__ROOT_noinline::not_fn_t<F> not_fn(F &&f)
60{
61 return __ROOT_noinline::not_fn_t<F>(std::forward<F>(f));
62}
63}
64
65#endif
66
67#endif
#define f(i)
Definition RSha256.hxx:104
#define h(i)
Definition RSha256.hxx:106
TRObject operator()(const T1 &t1) const