21 #include <type_traits>
28 namespace property_impl {
30 template<
typename MP,
typename C,
typename T>
33 template<
typename MP,
typename C,
typename T>
42 T* get(C* _this)
const {
43 if(
auto sptr = (_this->*mp_).lock()) {
51 template<
typename MP,
typename C,
typename T>
60 T* get(C* _this)
const {
61 return (_this->*mp_).get();
65 template<
typename MP,
typename C,
typename T>
74 T* get(C* _this)
const {
75 return (_this->*mp_).get();
79 template<
typename MP,
typename C,
typename T>
81 static_assert(!std::is_function<MP>::value,
"MP was a function");
90 T* get(C* _this)
const {
96 template<
typename MP,
typename C,
typename T>
105 T* get(C* _this)
const {
106 return (_this->*mp_)();
110 template<
typename MP,
typename C,
typename T>
114 static_assert(!std::is_pointer<T>::value,
"T was a pointer");
115 static_assert(!std::is_function<T>::value,
"T was a function");
122 T* get(C* _this)
const {
123 return &(_this->*mp_);
131 static_assert(!std::is_function<T>::value,
"T was a function");
138 typedef typename std::remove_pointer<T>::type type;
158 typedef typename std::remove_pointer<T>::type type;
162 template<
typename MP>
166 template<
typename T,
typename U>
168 typedef U class_type;
169 typedef T variable_type;
177 template<
typename MP>
180 template<
typename MP>
187 Property(class_type* _this, MP member):
195 getter_ = rhs.getter_;
204 inline operator T&()
const {
208 inline T* operator->()
const {
212 inline operator T*() {
217 return getter_.get(this_);
220 operator bool()
const {
return bool(get(
this));}
225 #define S_DEFINE_PROPERTY(name, member) \
226 Property<decltype(member)> name = {this, member}