lamarrr/STX

missing typename in TRY_OK/TRY_SOME

melak47 opened this issue · 1 comments

Describe the bug
When using the TRY_OK (or TRY_SOME) macros inside a template, and the expression involves the template arguments' types. decltype((result_expr))::value_type causes an error because of the missing dependent typename.

Adapting the "filesystem" example:

struct Dummy {
    auto open(std::string_view path) -> Result<File> {
        return ::fs::open(path);
    }
};

template<typename T>
auto example(T t) -> Result<File> {
    TRY_OK(file, t.open("example"));
    return file;
}

Causes:

error C7510: 'value_type': use of dependent type name must be prefixed with 'typename'

Expected behavior
The example compiles.

Compiler
VS2019 16.7.3

Desktop:

  • OS: Windows 10
  • Version 19041

Nice!
Thanks for the PR!
Much appreciated