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  * @defgroup FutureStandards Future C++ features
15  * @brief Features expected to be provided by future C++ standards.
16  */
17 
18 
19 /**
20  * Namespace anticipating some simple features of C++ standards not yet adopted.
21  *
22  * It is recommended that whenever all supported compilers support each single
23  * feature, that be removed from here, and the standard one immediately adopted.
24  *
25  * The aim is that the interface and behaviour here are as similar as possible,
26  * so that the update should boil down to a different header inclusion and a
27  * different namespace.
28  *
29  * @addtogroup FutureStandards
30  */
31 namespace util::pre_std {
32 
33 #if (__cplusplus < 202000L) // still to be defined, should be C++20
34 
35  /// Transparent functor that returns its argument just as passed.
36  struct identity {
37 
38  struct is_transparent {}; // STL algorithms will be happy to find this
39 
40  template <typename T>
41  constexpr T&& operator() (T&& t) const noexcept
42  { return std::forward<T>(t); }
43 
44  }; // identity<>
45 
46 #endif // (__cplusplus < 202000L)
47 
48 } // namespace pre_std
49 
50 
51 
52 #endif // LARCOREALG_COREUTILS_FROMFUTUREIMPORT_H
constexpr T && operator()(T &&t) const noexcept
Transparent functor that returns its argument just as passed.