On 2/16/2016 3:15 AM, Stefan Ram wrote:
>
> Can you improve my first attempt, so that we have a
> call syntax in the form
>
> »is_alpha« leftparen int-expression rightparen
>
> where the compiler complains when there is anything
> else than an int-expression between the parens
> (which could be »()«, »{}«, »[]«, or »<>«) and the
> semantics are those of »::std::isalpha«?
Yes, you can make it a template and use SFINAE like `std::enable_if`
(or, shameless plug, [1]`cppx::If_`, which provides a more clean and
more readable conventional “if-else” notation for the same).
Using a template is a general solution to avoid various kinds of
argument type decay.
In particular it's a solution to the problem of providing overloads
where one accepts pointer and the other accepts array.
Cheers & hth.,
- Alf
Notes:
[1] <url:
https://github.com/alf-p-steinbach/cppx/blob/plutonium/core_language_support/tmp/If_.hpp>