https://bugs.llvm.org/show_bug.cgi?id=36469

            Bug ID: 36469
           Summary: std::invoke of std::optional::has_value
                    pointer-to-member-function fails, due to its class
                    type being a private base.
           Product: libc++
           Version: 4.0
          Hardware: All
                OS: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: ari...@stack.nl
                CC: llvm-bugs@lists.llvm.org, mclow.li...@gmail.com

The following code snippet:

    #include <functional>
    #include <optional>

    bool testfn(std::optional<int> opt_int) {
      return std::invoke(&std::optional<int>::has_value, opt_int);
    }

Compiler output (c++ -std=c++1z -c -o test.o test.cc):

    test.cc:5:10: error: no matching function for call to 'invoke'
      return std::invoke(&std::optional<int>::has_value, opt_int);
             ^~~~~~~~~~~
    /usr/include/c++/v1/functional:2589:1: note: candidate template ignored:
substitution failure [with _Fn = bool
          (std::__1::__optional_storage_base<int, false>::*)() const noexcept,
_Args = <std::__1::optional<int> &>]: no type named 'type' in
          'std::__1::result_of<bool (std::__1::__optional_storage_base<int,
false>::*&&(std::__1::optional<int> &))() const noexcept>'
    invoke(_Fn&& __f, _Args&&... __args)
    ^
    1 error generated.

(I have a hard time reading the error message, but it looks to me like
std::result_of template argument is a zero-argument function that returns a
function.)

Compiler version:
    FreeBSD clang version 4.0.0 (tags/RELEASE_400/final 297347) (based on LLVM
4.0.0)
    Target: x86_64-unknown-freebsd11.1
    Thread model: posix
    InstalledDir: /usr/bin

Additionally, the following snippet does not compile, while to me seems valid:

    std::optional<int> opt_int;
    auto fn_ptr = &std::optional<int>::has_value;
    bool manual_invocation = (opt_int.*fn_ptr)();

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to