1
- #include < functional>
2
-
3
1
namespace detail {
4
2
template <typename T> struct Quux {};
5
3
} // namespace detail
6
4
7
5
using FuncPtr = detail::Quux<double > (*(*)(int ))(float );
8
6
9
7
struct Foo {
10
- template <typename T> void foo (T const &t ) const noexcept (true ) {}
8
+ template <typename T> void foo (T arg ) const noexcept (true ) {}
11
9
12
- template <size_t T> void operator <<(size_t ) {}
10
+ template <int T> void operator <<(int ) {}
13
11
14
12
template <typename T> FuncPtr returns_func_ptr (detail::Quux<int > &&) const noexcept (false ) { return nullptr ; }
15
13
};
16
14
17
15
namespace ns {
18
- template <typename T> int foo (T const &t) noexcept (false ) { return 0 ; }
16
+ template <typename T> int foo (char const *str) noexcept (false ) { return 0 ; }
17
+ template <typename T> int foo (T t) { return 1 ; }
19
18
20
19
template <typename T> FuncPtr returns_func_ptr (detail::Quux<int > &&) { return nullptr ; }
21
20
} // namespace ns
@@ -24,20 +23,20 @@ int bar() { return 1; }
24
23
25
24
namespace {
26
25
int anon_bar () { return 1 ; }
27
- auto anon_lambda = [](std::function< int ( int (*)( int ))>) mutable {};
26
+ auto anon_lambda = [] {};
28
27
} // namespace
29
28
30
29
int main () {
31
- ns::foo (bar);
32
- ns::foo (std::function{ bar} );
30
+ ns::foo< decltype (bar)> (bar);
31
+ ns::foo< decltype ( bar)>( " bar " );
33
32
ns::foo (anon_lambda);
34
- ns::foo (std::function{ anon_bar} );
35
- ns::foo (&Foo::foo<std::function< int (int )>> );
33
+ ns::foo (anon_bar);
34
+ ns::foo< decltype (&Foo::foo<int (int )>)>( " method " );
36
35
ns::returns_func_ptr<int >(detail::Quux<int >{});
37
36
Foo f;
38
- f.foo (std::function{bar});
39
- f.foo (std::function{anon_bar});
37
+ f.foo (anon_bar);
40
38
f.operator << <(2 > 1 )>(0 );
41
39
f.returns_func_ptr <int >(detail::Quux<int >{});
40
+
42
41
return 0 ;
43
42
}
0 commit comments