草庐IT

size_type

全部标签

c++ - 我应该如何在恒定长度的 STL 样式数据结构中实现 max_size?

假设我实现了一个类似于动态数组的常量数据结构。即,我给数据结构一个长度l在构造函数中。然后,该数据结构的实例将永远无法容纳比l更多的元素。.我希望该数据结构具有尽可能接近STL的接口(interface)。我应该如何实现max_size这个类的方法?应该是容量l在构造函数中给出?或者应该是std::numeric_limits::max()?此方法的文档说:Returnsthemaximumnumberofelementsthecontainerisabletoholdduetosystemorlibraryimplementationlimitations,i.e.std::dist

c++ - 继承类中的 shared_from_this() 类型错误(是否有 dyn.type-aware 共享指针?)

我有一个使用enable_shared_from_this的ViewController基类classViewController:publicstd::enable_shared_from_this{//...};和一个child:classGalleryViewController:publicViewController{voidupdateGallery(floatdelta);}问题出现了,当我尝试将我当前的实例传递给第3方时(比如lambda函数被安排在某处)实例(GalleryViewController)会释放一个(罕见的)条件,所以我不能直接捕获“this”,我需要用

c++ - Eigen 与 -O3 警告 : argument 1 value ‘X’ exceeds maximum object size Y

发生了什么当我按照教程onEigenwebsite尝试将Eigen::Vector3f添加到std::vector中时像这样:#include#include#includetemplateusingEigenStdVector=std::vector>;intmain(){EigenStdVectorvec;vec.emplace_back(1.0f,1.0f,1.0f);std::cerr我收到以下警告:Infileincludedfrom/usr/include/eigen3/Eigen/Core:349:0,from/home/igor/Code/eigen_example/e

Bean named ‘ddlApplicationRunner‘ is expected to be of type ‘org.springframework.boot. Runner‘ 。。。

springboot整合mybatisplus时遇见报错错误信息:Beannamed'ddlApplicationRunner'isexpectedtobeoftype'org.springframework.boot.Runner'butwasactuallyoftype'org.springframework.beans.factory.support.NullBean'atorg.springframework.beans.factory.support.AbstractBeanFactory.adaptBeanInstance(AbstractBeanFactory.java:410)

c++ - 无法识别的类型 - 'Error: Variable "[var-name ]"is not a type name'

作为项目的一部分,我正在创建一个处理物理的类。我们被告知要使用一个处理任意行为的类。我创建了一个类,它将根据提供给它的模块更新内部状态(代码如下)。但是,表示内部状态的结构PhysicsData除了它自己的文件外,在任何地方都无法识别。任何人都可以解释一下吗?(对于大量信息的转储,我们深表歉意,但是问题所在的对象和问题所在的位置之间的差距非常大,减少额外的细节也会删除可能有用的上下文)这里是有问题的结构:#pragmaonce//Thisfile"PhysicsBehaviourBase.h"#include#includestructPhysicsData{public:D3DXVE

c++ - 为什么我得到 "recursive type or function dependency context too complex"?

为什么此代码在VisualC++中会产生以下错误?是编译器的错误还是代码无效?templateinttest(int=sizeof(test()));templateinttest(int);intmain(){returnsizeof(test());}Recursivetypeorfunctiondependencycontexttoocomplex 最佳答案 test在您使用它时尚未声明。C++11中经常出现类似的问题:templateautotest()->decltype(test());templateautotest(

解决SpringBoot启动失败:A component required a bean of type ‘xxxxxxx‘ that could not be found.

问题描述今天写了一个MD5加密加盐工具类,运用到实际业务代码中缺报错了,内容如下:***************************APPLICATIONFAILEDTOSTART***************************Description:Acomponentrequiredabeanoftype'com.wyh.util.SaltMD5Util'thatcouldnotbefound.Action:Considerdefiningabeanoftype'com.wyh.util.SaltMD5Util'inyourconfiguration.分析问题根据错误日志不难发现

c++ - 调试断言失败_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)

我遇到了这个问题:调试断言失败!文件:f:\dd\vctools\crt_bld\self_x86\crt\dbgdel.cpp第52行表达式“_BLOCK_TYPE_IS_VALID(pHead->nBlockUse)我的程序正确地将所有值返回到我期望的屏幕,但是这个问题让我紧张...#include#include#includeusingnamespacestd;double*wsk1;double*wsk2;double*wsk3;double*kopiowanie(double*wsk1,double*wsk2,double*wsk3);double*zaladuj(doub

c++ - Vector size() 返回看似随机的大整数

我正在编写一个作业程序,遇到了一个奇怪的问题。当尝试使用size()函数获取二维vector的大小时,我得到看似随机的大整数,这使我的程序无法运行。我需要大小来访问vector中的元素。我的头文件:#ifndef_MATRIX_H#define_MATRIX_H#include#includeclassMatrix{private://intdimension;std::vector>matrix;public:Matrix();Matrix(std::vector>);voidprint();Matrixoperator-(Matrixoperand);};#endif我的实现文件:

c++ - 前向声明 : incomplete type 'enums::Category' used in nested name specifier 有问题

我想要一个围绕枚举的包装器,这将使我有机会将其转换为字符串,反之亦然。基类如下:templateclassStringConvertedEnum{public:staticstd::stringtoString(TEnume);staticTEnumtoEnum(std::string&str);protected:staticconststd::map_stringMapping;staticconststd::map_enumMapping;};然后我想要这样的东西:classCategory:publicStringConvertedEnum{public:enumEnum{Ca