为什么std :: begin使用尾随返回类型语法?

Dan*_*ica 3 c++ return decltype auto c++11

范围访问函数std::begin声明如下(对于容器):

template< class C >
auto begin( C& c ) -> decltype(c.begin());
Run Code Online (Sandbox Code Playgroud)

我只是想知道为什么不简单

template< class C >
decltype(C::begin) begin( C& c );
Run Code Online (Sandbox Code Playgroud)

这两者有什么区别吗?

use*_*670 8

等效的代码是

template< class C >
decltype(::std::declval<C &>().begin()) begin( C& c );
Run Code Online (Sandbox Code Playgroud)

这个更长,可能更容易出错.