All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fromFutureImport.h
Go to the documentation of this file.
1 /**
2  * @file larcorealg/CoreUtils/fromFutureImport.h
3  * @brief Code that might appear as standard C++ in the future.
4  * @author Gianluca Petrillo (petrillo@slac.stanford.edu)
5  * @date April 25, 2019
6  *
7  * This is currently a header-only library.
8  */
9 
10 #ifndef LARCOREALG_COREUTILS_FROMFUTUREIMPORT_H
11 #define LARCOREALG_COREUTILS_FROMFUTUREIMPORT_H
12 
13 
14 #include <utility> // std::forward()
15 
16 /**
17  * @defgroup FutureStandards Future C++ features
18  * @brief Features expected to be provided by future C++ standards.
19  */
20 
21 
22 /**
23  * Namespace anticipating some simple features of C++ standards not yet adopted.
24  *
25  * It is recommended that whenever all supported compilers support each single
26  * feature, that be removed from here, and the standard one immediately adopted.
27  *
28  * The aim is that the interface and behaviour here are as similar as possible,
29  * so that the update should boil down to a different header inclusion and a
30  * different namespace.
31  *
32  * @addtogroup FutureStandards
33  */
34 namespace util::pre_std {
35 
36 #if (__cplusplus < 202000L) // still to be defined, should be C++20
37 
38  /// Transparent functor that returns its argument just as passed.
39  struct identity {
40 
41  struct is_transparent {}; // STL algorithms will be happy to find this
42 
43  template <typename T>
44  constexpr T&& operator() (T&& t) const noexcept
45  { return std::forward<T>(t); }
46 
47  }; // identity<>
48 
49 #endif // (__cplusplus < 202000L)
50 
51 } // namespace pre_std
52 
53 
54 
55 #endif // LARCOREALG_COREUTILS_FROMFUTUREIMPORT_H
Transparent functor that returns its argument just as passed.
constexpr T && operator()(T &&t) const noexcept