【发布时间】:2010-10-25 18:12:12
【问题描述】:
如何获得对特定元组实例的“get”函数的引用?
下面给出了我最好的尝试,但不能针对 g++4.5.1 进行编译
#include <tuple>
#include <string>
typedef std::tuple<int,std::string> Tuple;
auto t=(std::string& (Tuple&))(std::get<1,Tuple>);
编译错误是:
a.cc:5: error: invalid cast to function type ‘std::string&(Tuple&)’
a.cc:5: error: unable to deduce ‘auto’ from ‘<expression error>’
我想将函数引用用作某些 stl 算法的输入。实际上,我对这对我来说似乎是多么的不平凡感到有点惊讶。
【问题讨论】: