ARMmbed / core-util

DEPRECATED: Mbed 3 utilities library
Other
12 stars 17 forks source link

Forbid copying of core-util container classes #62

Closed bogdanm closed 8 years ago

bogdanm commented 8 years ago

The core-util allocators (PoolAllocator, ExtendablePoolAllocator, Array and BinaryHeap) don't have well defined copy semantics, thus it's better to explicitly forbid copying than to rely on the copy constructors and assignment operators generated automatically by the compiler.

Fixes #11.

bogdanm commented 8 years ago

@bremoran @0xc0170

bogdanm commented 8 years ago

Updated with move copy constructor/assignment operator and =delete

bogdanm commented 8 years ago

@bremoran @0xc0170

0xc0170 commented 8 years ago

Do we want them to be private? A compiler issues an additional error that they are not accessible (besides "use of delete function").

// private + delete
In function 'int main()': 
10:5: error: 'Test::Test(const Test&)' is private 
16:10: error: within this context 
16:10: error: use of deleted function 'Test::Test(const Test&)' 10:5: note: declared here

//public + delete
In function 'int main()': 
15:10: error: use of deleted function 'Test::Test(const Test&)' 
9:5: note: declared here

LGTM

bogdanm commented 8 years ago

I honestly have no idea if it's better to keep them private rather than public or the other way around.

bremoran commented 8 years ago

I'd say that one compiler error is better than two. I also like the =delete syntax. However, I think that we should pick one: either private or = delete, not both.

bogdanm commented 8 years ago

Ok, deleted operators and constructors are public now. Can we merge this?

bremoran commented 8 years ago

LGTM

0xc0170 commented 8 years ago

+1