You can tell the logging services software was knocked up quickly... I completely forgot to use C++11 smart pointers[1] as part of the expressed RAII design pattern. Consequently the destructor was busy doing the pointer deleting idioms so familiar of C++03 (even if it did use the C++11 range based for loop to do it!). The changes also utilise the C++11 approach alias creation as replacement for typedef[2].
TL;DR The logging services code uses smart pointers now, but where it makes sense and not where it would make usage verbose and obfuscated.
This failure to implement the intended guarded approach to resources propagates back to the seralizor_policy class that has now done away with the public close() method in favour of having the destructor tidy up - as it should:
Okay that's better.
So to set up the smart pointer usage I knocked up a couple of aliases to reduced code clutter and obfuscation:
Well that was easy!
Or was it...?
Because now in order to use logger the instantiation of the shared_ptr guarded stamp_policy(s) the code is now verbose and obfuscates the intention:
YUCK!
For the sake of saving a few lines in the destructor this is just not worth to the end user (me).
So with a quick change to the alias the job is fixed!
References:
[1] Using C++11 Smart Pointers - Kieras (2013)
[2] What is the difference between 'typedef' and 'using' in C++11? (2012)
No comments:
Post a Comment