reference_wrapper导致"incomplete type is not allowed"
reference_wrapper cause "incomplete type is not allowed"
#include <vector>
#include <array>
int main() {
typedef std::array<int,2> point;
typedef std::vector<std::reference_wrapper<point>> route;
std::vector<std::vector<point>> lattice = {
{point{ {0,0} },point{ {0,1} }},
{point{ {1,0} },point{ {1,1} }}
};
route r = {&lattice[0][0],&lattice[0][1]};
point last = r.back().get();
}
最后一行不会编译,因为"不允许不完整的类型"。当我在互联网上搜索时,一篇论文似乎解决了这个问题:http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0357r3.html。那篇论文刚好高于我的水平。所以我不确定。有人会确认或解决这个问题吗?
此外,还赞赏解决方法:
我正在尝试将路由存储在一个不那么大的格子上。会有很多路线(密集在格子中(。所以,我在想,在一条路线中,存储点的参考而不是点,以节省内存。
在使用std::reference_wrapper
之前必须#include <functional>
。
相关文章:
- Directx 11 - CompileFromFile() is not compiling
- Centos7 g++ "to_string is not in a member of std"
- 将成员函数作为构造函数参数调用时出错 "Variable is not a type name"
- reference_wrapper导致"incomplete type is not allowed"
- 结构中的错误"Incomplete type is not allowed"
- "Called Object Type is Not a Function or Pointer" 与 typedef 和类
- 无法创建 DLL:获取 DLL "is not a valid Win32 application"
- Atom gpp编译器给出"'C:UsersadminUser' is not recognized as an internal or..."错误
- 当我编译XG-Bosst时,出现错误"error: 'Split' is not a member of 'xgboost::common' ……"
- C++ DLL 运行时错误"abc.dll is not a valid WIN32 application" 。请帮助解决这个问题
- 如何修复 eigen3 中的'non-type template argument is not a constant expression'?
- 我的代码应该接受一个数字,并返回字母等级或"Grade is not valid"但 else 语句不起作用
- 如何修复此错误"the value of 'x1' is not usable in a constant expression"?static_assert
- 加载安全区图像"A device attached to the system is not functioning"
- 巴泽尔中的错误"name 'new_local_repository' is not defined"
- 如何修复 SDL2 "GLSL 3.30 is not supported"错误
- 函数模板(它是类模板的成员)的显式专用化会产生"partial specialization is not allowed"错误,为什么?
- 为什么"an inherited constructor is not a candidate for initialization from an expression of the same or
- CGAL 绘制函数在 Visual Studio 中给出'CGAL_USE_BASIC_VIEWER is not defined'错误
- "OpenCV Error: The function/feature is not implemented"安卓应用程序