#include <cstddef>
template <class Src, class Dest> Dest* transfer_cv(Src *, Dest *p) { return p; }
template <class Src, class Dest> const Dest* transfer_cv(const Src *, Dest *p) { return p; }
template <class Src, class Dest> volatile Dest* transfer_cv(volatile Src *, Dest *p) { return p; }
template <class Src, class Dest> const volatile Dest* transfer_cv(const volatile Src *, Dest *p) { return p; }
#define property_enable(type) typedef type property_container_type
#define property_this transfer_cv( this, container_from_property(this) )
template <class Value>
struct property_base
{
typedef Value value_type;
value_type value;
};
#define property struct : property_base
#define property_set(...) void operator =(__VA_ARGS__)
#define property_get(...) operator __VA_ARGS__()
#define property_make(name) name; \
static property_container_type* container_from_property(const volatile decltype(name)* p) \
{ \
return (property_container_type*) ((char*) p - offsetof(property_container_type, name)); \
}
#include <iostream>
struct asdf {
property_enable(asdf);
float myFloat;
property<int>
{
property_set(int new_value) {
value = new_value * 2;
std::cout << "my float:" << property_this->myFloat << std::endl;
}
property_get(int) const {
return value - 1;
}
} property_make(member)
};
int main()
{
asdf x = { 2.0f };
x.member = 5;
std::cout << x.member;
}
I2luY2x1ZGUgPGNzdGRkZWY+CiAKdGVtcGxhdGUgPGNsYXNzIFNyYywgY2xhc3MgRGVzdD4gRGVzdCogdHJhbnNmZXJfY3YoU3JjICosIERlc3QgKnApIHsgcmV0dXJuIHA7IH0KdGVtcGxhdGUgPGNsYXNzIFNyYywgY2xhc3MgRGVzdD4gY29uc3QgRGVzdCogdHJhbnNmZXJfY3YoY29uc3QgU3JjICosIERlc3QgKnApIHsgcmV0dXJuIHA7IH0KdGVtcGxhdGUgPGNsYXNzIFNyYywgY2xhc3MgRGVzdD4gdm9sYXRpbGUgRGVzdCogdHJhbnNmZXJfY3Yodm9sYXRpbGUgU3JjICosIERlc3QgKnApIHsgcmV0dXJuIHA7IH0KdGVtcGxhdGUgPGNsYXNzIFNyYywgY2xhc3MgRGVzdD4gY29uc3Qgdm9sYXRpbGUgRGVzdCogdHJhbnNmZXJfY3YoY29uc3Qgdm9sYXRpbGUgU3JjIC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