jeudi 7 février 2019

Member function template deduction guide or other method to let the compiler know how to call function

struct setup_entry 
{
    template< typename T >
    void Disable( bool(*p)(T*) ) { ... }
}

Calling Disable:

setup_entry X;

Case 1: X.Disable( [](int*)->bool{...} );        //FAIL to deduce T
Case 2: X.Disable<int>( [](int*)->bool{...} );   //OK   to deduce T

I would like to use case 1. (Easier for the user)

Any ideas?

Aucun commentaire:

Enregistrer un commentaire