TartanLlama / expected

C++11/14/17 std::expected with functional-style extensions

Home Page:https://tl.tartanllama.xyz

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tl::unexpected("Some string") does not compile

scottschurr opened this issue · comments

The tl::unexpected class template infers tl:unexpected("Some string") with E as type char [22], not char const*.

I can use tl::unexpected<char const*>("Some string") as a work around, so it's not the end of the world.

However in C++17 it feels like a deduction guide along the lines of...

template <typename E, std::size_t N>
unexpected(E(&)[N]) -> unexpected<E const*>;

... would make tl::unexpected better behaved for this situation.

I'm not submitting a pull request because...

  • tl::expected.hpp is not executing correctly in my environment, so I can't test the results.
  • I don't know how to properly guard the deduction guide so it's only available for C++17 in this file.

But I figured I could at least pass the suggestion along. Thanks for reading.

Fixed in fb0bd6e