What is ‘operator auto’ in C++?

When auto is used in user-defined conversion function the type will be deduced via return type deduction, i.e. int for this case (0). This was introduced in C++14.

The placeholder auto can be used in conversion-type-id, indicating a
deduced return type:

struct X {
    operator int(); // OK
    operator auto() -> short;  // error: trailing return type not part of syntax
    operator auto() const { return 10; } // OK: deduced return type
};

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)