草庐IT

data_size

全部标签

c++ - 为什么 std::allocator<>::deallocate() 有一个未使用的 size_type 参数?

使用std::allocator时,deallocate函数需要pointer参数,和一个size_type参数(std::allocator::deallocate(std::allocator::pointerp,std::allocator::size_type)。但是,没有使用size_type,也不是可选的。那么为什么它在那里?这让我很困惑,因为它应该是可选的,甚至不在那里,因为它没有在函数中使用.编辑:MSVC的分配器实现deallocatevoiddeallocate(pointer_Ptr,size_type){//deallocateobjectat_Ptr,igno

Hibernate:即使我在配置文件中设置了batch_size,为什么还要手动flush()?

我正在学习使用Java的Hibernate5.2.10。我从网上的一些教程开始,但面临以下问题。使用批处理时,我看到的所有教程首先设置hibernate.jdbc.batch_size在配置文件中。之后,代码与此相似:Sessionsession=SessionFactory.openSession();Transactiontx=session.beginTransaction();for(inti=0;i我为什么要做flush()和clear()手动?这不是应该通过冬眠自动完成的事情,因为我已经设置了hibernate.jdbc.batch_size在配置文件中?对我来说,似乎我正在手动进

Global SiC MOSFET Modules Market Size Is Projected to Grow from USD 1693 million in 2023

Accordingtothenewmarketresearchreport“GlobalSiCMOSFETModulesMarketReport2023-2029”,publishedbyGlobalInfoResearch,theglobalSiCMOSFETModulesmarketsizeisprojectedtogrowfromUSD1693millionin2023toUSD9218.2millionby2029,ataCAGRof32.6%duringtheforecastperiod.Figure.GlobalSiCMOSFETModulesMarketSize (US$Mill

c++ - 如果 new_size 不大于旧的,C++ 标准是否保证 std::string::resize(new_size) 不会导致分配?

这个问题在这里已经有了答案:Doesthestandardguarantee,thatstd::string::resizewillnotdoreallocatememory,ifthenewsizeislessthanorequaltoastheoldone?(1个回答)关闭3年前。#include#includeintmain(){autos="hello"s;autop=&s[0];s.resize(3);assert('h'==*p);//alwaysok?}如果new_size不大于旧的,C++标准是否保证std::string::resize(new_size)不会导致分配

c++ - 为什么从 size_t 转换为 unsigned int 会给我一个警告?

我有代码:unsignedintlength=strlen(somestring);我正在编译警告级别为4,它告诉我“从size_t到unsignedint的转换,当size_t时可能丢失数据”是typedef对于unsignedint.为什么!?编辑:我刚刚解决了我自己的问题。我是XP用户,我的编译器正在检查64位兼容性。自size_t取决于平台,对于64位,它将是unsignedlonglong,这与unsignedint不同. 最佳答案 因为unsignedint在您的机器上是比size_t更窄的类型。size_t很可能是64

c++ - 为什么 stdarg.h 有一个宏 « __va_size »?

我正在寻找一些关于宏的代码,我找到了这样的代码,用于宏«va_start»:#define__va_argsiz(t)\(((sizeof(t)+sizeof(int)-1)/sizeof(int))*sizeof(int))#defineva_start(ap,pN)\((ap)=((va_list)(&pN)+__va_argsiz(pN)))我想知道«__va_argsiz»函数的目标到底是什么。是对齐限制吗?谢谢! 最佳答案 C中的对齐和默认类型提升规则。 关于c++-为什么st

c++ - C++14 是否要求删除表达式必须调用 `void operator::delete(void*, std::size_t)` 而不是 `void::operator delete(void*)` ?

根据thisvoidoperatordelete(void*);(1)voidoperatordelete[](void*);(2)voidoperatordelete(void*,conststd::nothrow_t&);(3)voidoperatordelete[](void*,conststd::nothrow_t&);(4)voidoperatordelete(void*,std::size_t)(5)voidoperatordelete[](void*,std::size_t)(6)voidoperatordelete(void*,std::size_t,conststd:

带负操作数的 C++ size_t 模运算

因此,模运算可以为您提供三个值:然后:-7%5=3(数学,余数>=0)-7%5=-2(C++)-7%(size_t)5=4(C++)另一个例子:-7%4=1(数学,余数>=0)-7%4=-3(C++)-7%(size_t)4=1(C++)当左手操作数为正时,三种方法的答案都是一样的。但是对于负值,他们似乎都有自己的方法。C++中无符号操作数取模运算的值是如何计算的? 最佳答案 这就是混合有符号和无符号值时发生的情况——困惑![C++14:5.6/2]:Theoperandsof*and/shallhavearithmeticorun

c++ - 是否必须释放 std::string.c_str() 或 std::string.data() 返回的指针?

据我所知,当您调用c_str()/data()时,std::string会创建其内容的标识数组拷贝方法(有/没有终止NUL-char,在这里无关紧要)。不管怎样,对象是否也负责释放这个数组,还是我必须这样做?简而言之:std::stringhello("content");constchar*Ptr=hello.c_str();//useit....delete[]Ptr;////really???我只是想在内存分配方面保持安全。 最佳答案 不,您不需要释放ptr指针。ptr指向位于内部位置某处的不可修改字符串(实际上这是编译器的实

c++ - libstdc++ 的 std::vector<bool>::data 有什么作用?

根据标准,std::vector没有成员函数data().但是,以下代码片段可以使用带有libstdc++的最新GCC正常编译:#includeintmain(){std::vectorv;v.data();}如果我们尝试使用结果,结果返回类型是void.这是一些gcc扩展还是一个错误?如果前者为真,它有什么作用? 最佳答案 我的/usr/include/c++/4.8/bits/stl_bvector.h有://_GLIBCXX_RESOLVE_LIB_DEFECTS//DR464.Suggestionfornewmemberfu