Files
StorytellersBestFriend/sbf-cpp/Questions.md
2023-04-12 22:11:23 -07:00

472 B

Why do I have to cast std::nullopt to a specific optional type when calling a templated function i.e.

template<typename T>
void DoSomething(std::optional<T> = std::nullopt, bool report_errors = false);
DoSomething() works fine.
DoSomething(std::nullopt, true) no matching function for call to 'DoSomething' Do_Something<std::optional<string>, bool>(

Which is uglier

(*after_each)()
after_each->operator()()
after_each.value()();