facebook / facebook/folly

MSVC compile error safe_closure

Open
#2,536 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
30.5k
Forks
5.9k
PR merge metrics
No merged PRs in 30d

Description

Use msvc to test `safe_closure` example from `SafeClosure.md`,got C7746 error
```c++
std::string s = "hello";
auto fn = safe_closure(
bind::args{
s, // copy s into closure
std::move(s), // move s into closure
std::string{"world"}}, // construct and move prvalue
// These all deduce to `const std::string&` -- see the next section
[](auto& a, auto& b, auto& c) { return a + " " + b + " " + c; });
```

```
1>folly\lang\SafeClosure.h(117,43): error C7746: 'ArgBIs': cannot appear in its own initializer
1> (compiling source file '../../../tests/bind_test.cpp')
1> folly\lang\SafeClosure.h(117,43):
1> the template instantiation context (the oldest one first) is
1> tests\bind_test.cpp(29,25):
1> see reference to function template instantiation 'auto folly::safe_closure,folly::detail::lite_tuple::tuple>>::operator ()<>(void) &' being compiled
1> with
1> [
1> Fn=BindTest_bindsimple_Test::TestBody::,
1> ST=std::basic_string,std::allocator>
1> ]

Contributor guide

Open the contributing guide

Research direction

Reproduce the MSVC failure from tests/bind_test.cpp using the safe_closure example in SafeClosure.md. Inspect folly/lang/SafeClosure.h around line 117 and the template instantiation shown in the error. Done means the example compiles successfully with MSVC and the relevant bind test passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.