Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:45

0001 /// \file ROOT/RNotFn.hxx
0002 /// \ingroup Base StdExt
0003 /// \author Danilo Piparo, Enrico Guiraud
0004 /// \date 2018-01-19
0005 
0006 /*************************************************************************
0007  * Copyright (C) 1995-2018, Rene Brun and Fons Rademakers.               *
0008  * All rights reserved.                                                  *
0009  *                                                                       *
0010  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0011  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0012  *************************************************************************/
0013 
0014 #ifndef ROOT_RNotFn
0015 #define ROOT_RNotFn
0016 
0017 #include <functional>
0018 
0019 // Backport if not_fn is not available.
0020 // libc++ does not define __cpp_lib_not_fn.
0021 // Assume we have not_fn if libc++ is compiled with C++14 and up.
0022 #if !defined(__cpp_lib_not_fn) && !(defined(_LIBCPP_VERSION) && __cplusplus > 201103L)
0023 
0024 #define R__NOTFN_BACKPORT
0025 
0026 #include "ROOT/TypeTraits.hxx" // InvokeInvokeResult_t
0027                                //
0028 #include <type_traits> // std::decay
0029 #include <utility>     // std::forward, std::declval
0030 
0031 namespace std {
0032 
0033 namespace __ROOT_noinline {
0034 template <typename F>
0035 class not_fn_t {
0036    std::decay_t<F> fFun;
0037 
0038 public:
0039    explicit not_fn_t(F &&f) : fFun(std::forward<F>(f)) {}
0040    not_fn_t(not_fn_t &&h) = default;
0041    not_fn_t(const not_fn_t &f) = default;
0042 
0043    template <class... Args>
0044    auto
0045    operator()(Args &&...args) & -> decltype(!std::declval<ROOT::TypeTraits::InvokeResult_t<std::decay_t<F>, Args...>>())
0046    {
0047       return !fFun(std::forward<Args>(args)...);
0048    }
0049    template <class... Args>
0050    auto operator()(Args &&...args)
0051       const & -> decltype(!std::declval<ROOT::TypeTraits::InvokeResult_t<std::decay_t<F> const, Args...>>())
0052    {
0053       return !fFun(std::forward<Args>(args)...);
0054    }
0055 };
0056 }
0057 
0058 
0059 template <typename F>
0060 __ROOT_noinline::not_fn_t<F> not_fn(F &&f)
0061 {
0062    return __ROOT_noinline::not_fn_t<F>(std::forward<F>(f));
0063 }
0064 }
0065 
0066 #endif
0067 
0068 #endif