Logo ROOT  
Reference Guide
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 
29 namespace std {
30 
31 namespace Detail {
32 template <typename F>
33 class not_fn_t {
34  typename std::decay<F>::type fFun;
35 
36 public:
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<typename std::result_of<typename std::decay<F>::type(Args...)>::type>())
44  {
45  return !fFun(std::forward<Args>(args)...);
46  }
47  template <class... Args>
48  auto operator()(Args &&... args) const & -> decltype(
49  !std::declval<typename std::result_of<typename std::decay<F>::type const(Args...)>::type>())
50  {
51  return !fFun(std::forward<Args>(args)...);
52  }
53 };
54 }
55 
56 
57 template <typename F>
58 Detail::not_fn_t<F> not_fn(F &&f)
59 {
60  return Detail::not_fn_t<F>(std::forward<F>(f));
61 }
62 }
63 
64 #endif
65 
66 #endif
f
#define f(i)
Definition: RSha256.hxx:104
F
#define F(x, y, z)
operator()
TRObject operator()(const T1 &t1) const
Definition: TRFunctionImport__oprtr.h:14
h
#define h(i)
Definition: RSha256.hxx:106
type
int type
Definition: TGX11.cxx:121