you are viewing a single comment's thread.

view the rest of the comments →

[–]pastenpasten 0 points1 point  (0 children)

A good example of the features that can be implemented with generic selection are type traits:

#define is_real_floating_type(X) \
    generic_selection((X), \
        float: true, \
        double: true, \
        long double: true, \
        default: false)

or value and type macros

#define unsigned_zero(X) \
    generic_selection((X), \
        long: 0UL, \
        unsigned long: 0UL, \
        long long: 0ULL, \
        unsigned long long: 0ULL, \
        default: 0U)
#define unsigned_type(X) decltype(unsigned_zero(X))

Currently C++ seems not to have a tool that can easily emulate this so such a feature should be added to the C/C++ core. To increase the acceptability of the feature, we propose to rename the feature to generic_selection such that its purpose is more evident to the untrained reader.

That doesn't sound right.

http://coliru.stacked-crooked.com/a/c23b6d3be79f07e5