Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement