[LLVMbugs] [Bug 16633] New: std::function return type cannot automatically cast to void
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Jul 16 01:26:15 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=16633
Bug ID: 16633
Summary: std::function return type cannot automatically cast to
void
Product: libc++
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: hhinnant at apple.com
Reporter: tatraian at deverto.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
I wrote the following c++ code:
#include <functional>
using namespace std;
bool fn(bool t){
return t;
}
int main(int argc, char** argv){
std::function<void ()> fns = std::bind(fn, true);
return 0;
}
This code can be compiled with g++ 4.7 with libstdc++ and clang (trunk
-r186306) also with libstdc++. But I cannot compile with libc++ (trunk -r
186237) I got the next error message:
tatraian at server09:~/Pilots$ clang++ -std=c++11 -stdlib=libc++ -lc++abi
-nostdinc++ -I/home/tatraian/llvm-svn-libcxx/include/c++/v1
-L/home/tatraian/llvm-svn-libcxx/lib/
-L/home/tatraian/tmp/llvm-svn-libcxxabi/lib/ bind.cc
bind.cc:11:28: error: no viable conversion from '__bind<bool (&)(bool), bool>'
to 'std::function<void ()>'
std::function<void ()> fns = std::bind(fn, true);
^ ~~~~~~~~~~~~~~~~~~~
/home/tatraian/llvm-svn-libcxx/include/c++/v1/functional:1138:5: note:
candidate constructor not viable: no known
conversion from '__bind<bool (&)(bool), bool>' to 'nullptr_t' for 1st
argument
function(nullptr_t) _NOEXCEPT : __f_(0) {}
^
/home/tatraian/llvm-svn-libcxx/include/c++/v1/functional:1139:5: note:
candidate constructor not viable: no known
conversion from '__bind<bool (&)(bool), bool>' to 'const
std::__1::function<void ()> &' for 1st argument
function(const function&);
^
/home/tatraian/llvm-svn-libcxx/include/c++/v1/functional:1140:5: note:
candidate constructor not viable: no known
conversion from '__bind<bool (&)(bool), bool>' to
'std::__1::function<void ()> &&' for 1st argument
function(function&&) _NOEXCEPT;
^
/home/tatraian/llvm-svn-libcxx/include/c++/v1/functional:1144:41: note:
candidate template ignored: disabled by
'enable_if' [with _Fp = std::__1::__bind<bool (&)(bool), bool>]
__callable<_Fp>::value &&
^
I think libc++' function takes care about return type. But I don't know if this
behaviour comes from C++ standard, or the standard says nothing about it or
just simply a bug.
In other way, it is logical that implicit cast does not work, but is there a
standard way to create a function object from an other function object that
differs only in return type (it changes return type to void)?
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130716/ebc1c157/attachment.html>
More information about the llvm-bugs
mailing list