Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
fwd_impl.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <fc/utility.hpp>
4#include <fc/fwd.hpp>
5#include <new>
6
7namespace fc {
8
9 namespace detail {
10 template<typename A, typename U>
11 struct add {
12 typedef decltype( *((A*)0) + *((typename fc::remove_reference<U>::type*)0) ) type;
13 };
14 template<typename A, typename U>
15 struct add_eq {
16 typedef decltype( *((A*)0) += *((typename fc::remove_reference<U>::type*)0) ) type;
17 };
18
19 template<typename A, typename U>
20 struct sub {
21 typedef decltype( *((A*)0) - *((typename fc::remove_reference<U>::type*)0) ) type;
22 };
24 template<typename A, typename U>
25 struct sub_eq {
26 typedef decltype( *((A*)0) -= *((typename fc::remove_reference<U>::type*)0) ) type;
27 };
28 template<typename A, typename U>
29 struct insert_op {
30 typedef decltype( *((A*)0) << *((typename fc::remove_reference<U>::type*)0) ) type;
31 };
32 template<typename A, typename U>
33 struct extract_op {
34 A* a;
35 U* u;
36 typedef decltype( *a >> *u ) type;
37 };
38 }
39
40
41 template<typename T, unsigned int S, typename U, typename A>
42 auto operator + ( const fwd<T,S,A>& x, U&& u ) -> typename detail::add<T,U>::type { return *x+fc::forward<U>(u); }
43
44 template<typename T, unsigned int S, typename U, typename A>
45 auto operator - ( const fwd<T,S,A>& x, U&& u ) -> typename detail::sub<T,U>::type { return *x-fc::forward<U>(u); }
46
47 template<typename T, unsigned int S, typename U, typename A>
48 auto operator << ( U& u, const fwd<T,S,A>& f ) -> typename detail::insert_op<U,T>::type { return u << *f; }
49
50 template<typename T, unsigned int S, typename U, typename A>
51 auto operator >> ( U& u, fwd<T,S,A>& f ) -> typename detail::extract_op<U,T>::type { return u >> *f; }
52
53 template<typename T, unsigned int S, typename A>
54 bool fwd<T,S,A>::operator !()const { return !(**this); }
55
56
57 template<uint64_t RequiredSize, uint64_t ProvidedSize>
58 void check_size() { static_assert( (ProvidedSize >= RequiredSize), "Failed to reserve enough space in fc::fwd<T,S>" ); }
59
60 template<typename T,unsigned int S,typename A>
61 template<typename... U>
62 fwd<T,S,A>::fwd( U&&... u ) {
64 new (this) T( fc::forward<U>(u)... );
65 }
66
67 template<typename T,unsigned int S,typename A>
72 template<typename T,unsigned int S,typename A>
75 new (this) T( *f );
76 }
77 template<typename T,unsigned int S,typename A>
78 fwd<T,S,A>::fwd( fwd<T,S,A>&& f ){
80 new (this) T( fc::move(*f) );
81 }
82
83
84
85 template<typename T,unsigned int S, typename A>
86 fwd<T,S,A>::operator T&() { return *(( T*)this); }
87 template<typename T,unsigned int S, typename A>
88 fwd<T,S,A>::operator const T&()const { return *((const T*)this); }
89
90 template<typename T,unsigned int S, typename A>
91 T& fwd<T,S,A>::operator*() { return *((T*)this); }
92 template<typename T,unsigned int S, typename A>
93 const T& fwd<T,S,A>::operator*()const { return *((const T*)this); }
94 template<typename T,unsigned int S, typename A>
95 const T* fwd<T,S,A>::operator->()const { return ((const T*)this); }
96
97 template<typename T,unsigned int S, typename A>
98 T* fwd<T,S,A>::operator->(){ return ((T*)this); }
99
100
101 template<typename T,unsigned int S, typename A>
103 ((T*)this)->~T();
104 }
105 template<typename T,unsigned int S, typename A>
106 template<typename U>
108 return **this = fc::forward<U>(u);
109 }
110
111 template<typename T,unsigned int S, typename A>
113 return **this = fc::move(*u);
114 }
115 template<typename T,unsigned int S, typename A>
116 T& fwd<T,S,A>::operator = ( const fwd<T,S,A>& u ) {
117 return **this = *u;
118 }
119
120} // namespace fc
121
Used to forward declare value types.
Definition fwd.hpp:11
bool operator!() const
Definition fwd_impl.hpp:54
const T * operator->() const
Definition fwd_impl.hpp:95
T & operator=(U &&u)
Definition fwd_impl.hpp:107
T & operator*()
Definition fwd_impl.hpp:91
namespace sysio::chain
Definition authority.cpp:3
auto operator+(const fwd< T, S, A > &x, U &&u) -> typename detail::add< T, U >::type
Definition fwd_impl.hpp:42
auto operator-(const fwd< T, S, A > &x, U &&u) -> typename detail::sub< T, U >::type
Definition fwd_impl.hpp:45
void check_size()
Definition fwd_impl.hpp:58
datastream< ST > & operator<<(datastream< ST > &s, const sysio::chain::may_not_exist< T > &v)
Definition abi_def.hpp:146
datastream< ST > & operator>>(datastream< ST > &s, sysio::chain::may_not_exist< T > &v)
Definition abi_def.hpp:152
#define T(meth, val, expected)
decltype(*((A *) 0)+=*((typename fc::remove_reference< U >::type *) 0)) type
Definition fwd_impl.hpp:16
decltype(*((A *) 0)+*((typename fc::remove_reference< U >::type *) 0)) type
Definition fwd_impl.hpp:12
decltype(*a > > *u) type
Definition fwd_impl.hpp:36
decltype(*((A *) 0)<< *((typename fc::remove_reference< U >::type *) 0)) type
Definition fwd_impl.hpp:30
decltype(*((A *) 0) -=*((typename fc::remove_reference< U >::type *) 0)) type
Definition fwd_impl.hpp:26
decltype(*((A *) 0) - *((typename fc::remove_reference< U >::type *) 0)) type
Definition fwd_impl.hpp:21
Definition dtoa.c:306