|
Boost : |
Subject: [boost] [utility] Any interest for a macro which automatically creates default move-semantics, comparisson etc for a class
From: Viktor Sehr (viktor.sehr_at_[hidden])
Date: 2013-11-06 12:38:44
I've created a macro which automatically creates:
- move constructor\assignment
- swap member function
- operator== and operator!=
- operator<
- assignment operator without side-effects if it throws.
Example usage:
class Foo {
public:
Foo() {}
DEFAULT_EVERYTHING(Foo,
( (int)(a) )
( (std::vector<int>)(b) )
( (float)(c) )
);
};
Any interest, suggestions or ideas?
Ofcourse it might be split into several macros depending on what operators
the class requests (if it's a move-only class etc), and perhaps an extra
parameter enable if a member is up for sorting and comparison.
Code available here:
https://www.dropbox.com/s/dhkxj94rrh83az0/DefaultEverything.h
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk