Molassembler  3.0.0
Molecule graph and conformer library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Binding.h
Go to the documentation of this file.
1 
8 #ifndef INCLUDE_TEMPLE_BINDING_H
9 #define INCLUDE_TEMPLE_BINDING_H
10 
11 #include <utility>
12 
13 namespace Scine {
14 namespace Molassembler {
15 namespace Temple {
16 
36 template<typename T>
37 struct Binding {
38  /* Since T is in a type-deducing context, T&& is a 'universal reference',
39  * and reference collapsing is applied!
40  */
41  using type = std::conditional_t<
42  std::is_rvalue_reference<T&&>::value || std::is_fundamental<std::decay_t<T>>::value,
43  std::decay_t<T>,
44  const T&
45  >;
46 
47  // Now the constructor can apply the same logic unconditionally
48  constexpr explicit Binding(T&& t) noexcept : value(t) {}
49  virtual ~Binding() = default;
50 
51  type value;
52 };
53 
54 } // namespace Temple
55 } // namespace Molassembler
56 } // namespace Scine
57 
58 #endif
Type that will own rvalues, reference lvalues.
Definition: Binding.h:37