On 03/11/2016 01:31 AM, Gavin Lambert wrote:
On 11/03/2016 16:50, Phil Bouchard wrote:
I don't really understand the proxy thing, but I sense possible trouble in a single API name apparently creating different behaviour depending on the first parameter type, especially when the remaining parameters appear to be forwarded constructor parameters. (What happens if you want to construct an object that takes a proxy as a parameter?)
The proxy ensures all sub allocations will be wiped out when it is destructed, cyclic or not.
Perhaps the first call should be to a method make_root_block and the second two to one called make_child_block, or something along those lines?
I am fixing the pointer again and now the proxy will have to be fully
explicit:
struct list {
public:
list() : root(x) {}
void clear() {
root.reset();
}
void insert() {
if(root.get() == 0) {
root = make_block<node>(x, x);
} else {
root->next = make_block<node>(x, x);
root->next->prior = root;
root = root->next;
}
}
~list()
{
}
private:
block_proxy x;
block_ptr<node> root;
};
But I guess I could define a new type like:
struct list {
public:
[...]
private:
block_root_ptr<node> root;
};
Where block_root_ptr could be something like:
template <typename T>
struct block_root_ptr : private block_proxy, public block_ptr<T>
{
block_root_ptr() : block_proxy(),
block_ptr<T>(static_cast