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