Run Code  | Code Wall  | Users  | Misc  | Feedback  | About  | Login  | Theme 

This wont compile :(

Language: Editor: Layout:
+ ] Compiler args + ] Show input
Compilation time: 0.33 sec, absolute service time: 0,45 sec 
edit mode |  history
Error(s):
source_file.cpp: In function ‘int main()’:
source_file.cpp:30:61: error: conversion from ‘main()::<lambda()>’ to non-scalar type ‘Foo {aka tag<std::function<void()>, Foo_tag>}’ requested
     Foo foo = [] { std::cout << "this is foo" << std::endl; };
                                                             ^
source_file.cpp:31:67: error: conversion from ‘main()::<lambda(auto:1)>’ to non-scalar type ‘Bar {aka tag<std::function<void(int)>, Bar_tag>}’ requested
     Bar bar = [](auto) { std::cout << "this is bar" << std::endl; };
                                                                   ^
source_file.cpp:32:73: error: conversion from ‘main()::<lambda(auto:2, auto:3)>’ to non-scalar type ‘Baz {aka tag<std::function<void(float, double)>, Baz_tag>}’ requested
     Baz baz = [](auto, auto) { std::cout << "this is baz" << std::endl; };
                                                                         ^
source_file.cpp: In instantiation of ‘decltype(auto) tag<T, <template-parameter-1-2> >::operator()(Args&& ...) [with Args = {float, double}; T = std::function<void(float, double)>; <template-parameter-1-2> = Baz_tag]’:
source_file.cpp:35:18:   required from here
source_file.cpp:17:33: error: no matching function for call to ‘forward(float&)’
   return t(std::forward<Args...>(args)...);
                                 ^
In file included from /usr/include/c++/5/bits/stl_pair.h:59:0,
                 from /usr/include/c++/5/bits/stl_algobase.h:64,
                 from /usr/include/c++/5/bits/char_traits.h:39,
                 from /usr/include/c++/5/ios:40,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iostream:39,
                 from source_file.cpp:1:
/usr/include/c++/5/bits/move.h:76:5: note: candidate: template<class _Tp> constexpr _Tp&& std::forward(typename std::remove_reference<_From>::type&)
     forward(typename std::remove_reference<_Tp>::type& __t) noexcept
     ^
/usr/include/c++/5/bits/move.h:76:5: note:   template argument deduction/substitution failed:
source_file.cpp:17:33: error: wrong number of template arguments (2, should be 1)
   return t(std::forward<Args...>(args)...);
                                 ^
In file included from /usr/include/c++/5/bits/stl_pair.h:59:0,
                 from /usr/include/c++/5/bits/stl_algobase.h:64,
                 from /usr/include/c++/5/bits/char_traits.h:39,
                 from /usr/include/c++/5/ios:40,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iostream:39,
                 from source_file.cpp:1:
/usr/include/c++/5/bits/move.h:87:5: note: candidate: template<class _Tp> constexpr _Tp&& std::forward(typename std::remove_reference<_From>::type&&)
     forward(typename std::remove_reference<_Tp>::type&& __t) noexcept
     ^
/usr/include/c++/5/bits/move.h:87:5: note:   template argument deduction/substitution failed:
source_file.cpp:17:33: error: wrong number of template arguments (2, should be 1)
   return t(std::forward<Args...>(args)...);
                                 ^