首页 > TAG信息列表 > c++14

c – 我可以在不提供参数的情况下生成函数吗?

所以c++17有std::function Deduction Guides所以给出: int foo(); 我可以: std::function bar(foo); 但我坚持使用c++14编译器.我必须做更多的事情:function< int()>巴(富).我想知道是否有办法创建一个std ::函数而不传递函数指针并明确提供函数签名?因此,例如make_pair将从它的参

c – 使用string_view进行地图查找

以下代码无法在最近的编译器上构建(g -5.3,clang -3.7). #include <map> #include <functional> #include <experimental/string_view> void f() { using namespace std; using namespace std::experimental; map<string, int> m; string s = "

c模板参数类型推断

我在C中有这样一个模板 template<typename T, T* P> struct Ptr {}; 所以我可以这样使用它: const int i = 0; Ptr<int, &i> ptr; 要么 Ptr<decltype(i), &i> ptr; 但我不想指定类型int或身份我两次,我想只使用 Ptr<&i> ptr; 让编译器自己找出int类型的部分. 如何声明我的模