Wandbox
SettingsLog
SettingsLog
Language
GitHubLogin
Ran/Viewed Log

Author

anonymous

about 7 years ago

Language

Compiler

Options

Author

anonymous

about 7 years ago

$
prog.cc: In lambda function:
prog.cc:11:27: error: inconsistent types 'std::nullopt_t' and 'std::optional<int>' deduced for lambda return type
     return std::optional(2);
                           ^
prog.cc:11:27: error: no matching function for call to 'std::nullopt_t::nullopt_t(std::optional<int>)'
In file included from /opt/wandbox/gcc-head/include/c++/9.0.0/bits/node_handle.h:39,
                 from /opt/wandbox/gcc-head/include/c++/9.0.0/bits/hashtable.h:37,
                 from /opt/wandbox/gcc-head/include/c++/9.0.0/unordered_map:46,
                 from /opt/wandbox/gcc-head/include/c++/9.0.0/functional:61,
                 from prog.cc:1:
/opt/wandbox/gcc-head/include/c++/9.0.0/optional:70:24: note: candidate: 'constexpr std::nullopt_t::nullopt_t(std::nullopt_t::_Construct)'
     explicit constexpr nullopt_t(_Construct) { }
                        ^~~~~~~~~
/opt/wandbox/gcc-head/include/c++/9.0.0/optional:70:24: note:   no known conversion for argument 1 from 'std::optional<int>' to 'std::nullopt_t::_Construct'
/opt/wandbox/gcc-head/include/c++/9.0.0/optional:60:10: note: candidate: 'constexpr std::nullopt_t::nullopt_t(const std::nullopt_t&)'
   struct nullopt_t
          ^~~~~~~~~
/opt/wandbox/gcc-head/include/c++/9.0.0/optional:60:10: note:   no known conversion for argument 1 from 'std::optional<int>' to 'const std::nullopt_t&'
/opt/wandbox/gcc-head/include/c++/9.0.0/optional:60:10: note: candidate: 'constexpr std::nullopt_t::nullopt_t(std::nullopt_t&&)'
/opt/wandbox/gcc-head/include/c++/9.0.0/optional:60:10: note:   no known conversion for argument 1 from 'std::optional<int>' to 'std::nullopt_t&&'
prog.cc: In function 'int main()':
prog.cc:18:24: error: static assertion failed: return type is still std::nullopt_t
     static_assert(std::is_same<return_type, std::optional<int>>{},
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prog.cc:21:27: error: 'struct std::nullopt_t' has no member named 'value'
     std::cout << lambda().value() << '\n';
                           ^~~~~
Exit Code:
1