How to obtain certain traits of delegates returned by functions in template constraints?

Jacob Carlborg doob at me.com
Sun Dec 15 02:44:38 PST 2013


On 2013-12-14 23:38, DoctorCaptain wrote:

> This is a very concise way to do what I want to do, but this check cares
> about other attributes of the function/delegate, i.e. if the function or
> delegate is designated as pure or nothrow and those don't show up in the
> check, it will fail. As in:
>
> auto nextGen()
> {
>      T genFunc(int x) nothrow
>      {
>          return 0;
>      }
>      return &genFunc;
> }
>
> genFunc will fail the is() check because the is check cares whether the
> delegate is nothrow or not. Since I want folks to be able to use my
> algorithm without caring about the implementation details, I need to
> provide constraints for the parameter lists and return types of their
> functions, but no constraints on whatever attributes they want to slap
> onto their functions. I will keep this in my toolbox, but I'll have to
> take the more long-winded approach this time around.

Hmm, there might be a way to strip all the attributes of a function.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list