Return type of consteval method, based on method argument

235 Views Asked by At

Consider following code:

template<typename... Arg>
class foo {
    [[nodiscard]]
    consteval static int stoi(std::string_view) { return 1; /* dynamically determined */ }

    consteval auto argOf(std::string_view i) -> std::tuple_element_t<stoi(i),std::tuple<Arg...>>
    {
        /* ... */
    }
};

as consteval input arguments must be compile time constants, and stoi guarantees that the return value is also compile time value, wouldn't code like this be valid from this point of view?

0

There are 0 best solutions below