Last active
June 7, 2019 23:57
-
-
Save zoecarver/d95320d274dfbb4bbd5a307a98c487af to your computer and use it in GitHub Desktop.
Uses allocator construction forward_as_tuple issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using namespace std; | |
template<class A, class... Args> | |
auto add_and_forward(A a, Args&&... args) | |
{ | |
return forward_as_tuple(a, forward<Args>(args)...); // <--- here is our issue | |
} | |
template<class A, class T1, class T2> | |
auto join(A a, T1 t1, T2 t2) | |
{ | |
return make_tuple(piecewise_construct, | |
apply([&a](auto&&... args) { | |
return add_and_forward(a, forward<decltype(args)>(args)...); | |
}, forward<T1>(t1)), | |
apply([&a](auto&&... args) { | |
return add_and_forward(a, forward<decltype(args)>(args)...); | |
}, forward<T2>(t2))); | |
} | |
template<class A, class T1, class T2> | |
auto foward_pair(A a, pair<T1, T2>&& p) | |
{ | |
return join(a, forward_as_tuple(move(p).first), | |
forward_as_tuple(move(p).second)); | |
} | |
struct Foo | |
{ | |
Foo(int, int) { } | |
}; | |
int main() | |
{ | |
auto p = make_pair(42, 101); | |
auto joined = foward_pair(1, move(p)); | |
make_from_tuple<pair<Foo, Foo>>(joined); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ignore the spacing. Github won't let me change it.