
Untitled
By: a guest on
Mar 10th, 2012 | syntax:
C++ | size: 0.47 KB | hits: 19 | expires: Never
extern "C" {
#include <stdint.h>
#include <netinet/in.h>
#include <arpa/inet.h>
}
class _getset_16 {
uint16_t* _x;
_getset_16() = delete;
public:
_getset_16(uint16_t& x) : _x(&x) { }
operator uint16_t () const { return ntohs(*_x); }
_getset_16& operator = (uint16_t y) { *_x = htons(y); return *this; }
};
class P {
uint16_t _x;
public:
_getset_16 x() { return _getset_16(_x); }
};
int main() {
P p;
p.x() = 2;
}