jeudi 18 octobre 2018

Function instance called must depend on parameter

I would like to make the function call depend on the parameter, that is, what version of the function is being called. I'm looking for a way to make the following code work, without making enum_value v a template argument. The goal is that if v==enum_value::A, the first instance is called. If v==enum_value::B the second instance must be called.

enum class enum_value { A, B, C };

auto foo(enum_value v) -> std::enable_if_t<v==enum_value::A>
{}

auto foo(enum_value v) -> std::enable_if_t<v==enum_value::B>
{}

Feel free to ask if I need to elaborate.

Aucun commentaire:

Enregistrer un commentaire