以下示例说明了我的问题:
#include <iostream>
#include <string>
template <typename T>
auto func(const T& x) -> decltype(to_string(x)) {
using std::to_string;
return to_string(x);
}
int main() {
std::cout << func(1);
}
我不想导入std::to_string
全局命名空间,也不想使用-> decltype(std::to_string(x))
,因为这样做会禁用 ADL。显然,您不能using std::to_string
放入decltype
. 那么,我该怎么做呢?