Add macro to ease creating tagged bools#2
Conversation
|
I waffled a bit on this, sorry. The two alternatives are my penultimate commit: #define AKT_MAKE_TAGGED_BOOL( Name ) \
class Name##ExplicitBoolTag { Name##ExplicitBoolTag() = delete; }; \
using Name = ::ak_toolkit::xplicit::tagged_bool< Name##ExplicitBoolTag >and my latest commit (using forward decl only): #define AKT_MAKE_TAGGED_BOOL( Name ) \
using Name = ::ak_toolkit::xplicit::tagged_bool< class Name##ExplicitBoolTag >The difference is whether one can re-use existing class names as tags. The former says no, the latter says yes. I don't see a strong use case for such re-use, and it probably violates the single responsibility principle by making a functional class do double duty as a tag. |
|
I find quite simple, and even if the DRY principle is not respected completely I fill this kind of macros make the code more obscure. |
|
Right: it's a trade-off, and totally optional. You can choose either to repeat yourself (boilerplate + tag name which is usually just Programmer's choice. |
This pull request adds a macro to eliminate boilerplate code when defining a tagged bool. At present, one has to do this to create some
tagged_bools:Or:
With this change, the macro handles the boilerplate: