Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <utility>
- // using forward
- #include <string>
- namespace {
- struct Foo
- {
- std::string bar;
- template<class std_string>
- Foo(std_string&& bar):
- bar(std::forward(bar))
- {}
- };
- }
- int main()
- {
- Foo baz(std::string(" "));
- return 0;
- }
- // clang error:
- // forward.cpp:13:11: error: no matching function for call to 'forward'
- // bar(std::forward(bar))
- // ^~~~~~~~~~~~
- // forward.cpp:21:7: note: in instantiation of function template specialization '<anonymous namespace>::Foo::Foo<std::basic_string<char> >' requested here
- // Foo baz(std::string(" "));
- // ^
- // /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/move.h:62:5: note: candidate template ignored: couldn't infer template argument '_Tp'
- // forward(typename std::remove_reference<_Tp>::type& __t)
- // ^
- // /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/move.h:67:5: note: candidate template ignored: couldn't infer template argument '_Tp'
- // forward(typename std::remove_reference<_Tp>::type&& __t)
- // ^
- // 1 error generated.
- // g++ error:
- // forward.cpp: In constructor '{anonymous}::Foo::Foo(std_string&&) [with std_string = std::basic_string<char>]':
- // forward.cpp:21:27: instantiated from here
- // forward.cpp:13:28: error: no matching function for call to 'forward(std::basic_string<char>&)'
- // forward.cpp:13:28: note: candidates are:
- // /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/move.h:62:5: note: template<class _Tp> _Tp&& std::forward(typename std::remove_reference<_Tp>::type&)
- // /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/bits/move.h:67:5: note: template<class _Tp> _Tp&& std::forward(typename std::remove_reference<_Tp>::type&&)
Advertisement
Add Comment
Please, Sign In to add comment