cppx-core
In_out_ref_.hpp
Go to the documentation of this file.
1 #pragma once // Source encoding: UTF-8 with BOM (π is a lowercase Greek "pi").
2 
3 #include <cppx-core/language/syntax/macro-use.hpp> // CPPX_USE_STD
4 #include <cppx-core/language/tmp/basic-Enable_if_.hpp> // cppx::Enable_if_
5 #include <cppx-core/language/tmp/basic-type-traits.hpp> // cppx::is_const_
6 
7 #include <functional> // std::(ref, reference_wrapper)
8 
9 namespace cppx
10 {
11  CPPX_USE_STD( ref, reference_wrapper );
12 
13  template< class Type
14  ,class = Enable_if_<not is_const_<Type>>
15  >
16  class In_out_ref_:
17  public reference_wrapper<Type>
18  {
19  template< class U, class > friend auto in_out_ref( U& o ) -> In_out_ref_<U>;
20 
21  In_out_ref_( Type& o ):
22  reference_wrapper<Type>( o )
23  {}
24 
25  public:
26  In_out_ref_( reference_wrapper<Type>&& ref ):
27  reference_wrapper<Type>( ref )
28  {}
29  };
30 
31  template<
32  class Type,
33  class = Enable_if_<not is_const_<Type>>
34  >
35  auto inline in_out_ref( Type& o )
37  { return In_out_ref_<Type>( o ); }
38 
39 } // namespace cppx
is_base_and_derived_, is_same_type_, is_a_, is_const_, is_class_, is_fixed_point_,...
auto in_out_ref(Type &o) -> In_out_ref_< Type >
Definition: In_out_ref_.hpp:35
Enable_if_ is just more readable than enable_if_t.
friend auto in_out_ref(U &o) -> In_out_ref_< U >
In_out_ref_(reference_wrapper< Type > &&ref)
Definition: In_out_ref_.hpp:26
CPPX_USE_STD(basic_string, basic_string_view, bitset, char_traits, size)
Macros for generating more concise and clear using statements, primarily $use_cppx and $use_std,...