草庐IT

value_type

全部标签

c++ - 警告 : value computed is not used

为什么我在“BIO_flush(b64);”行收到警告消息“警告:未使用计算值”我怎样才能摆脱它?unsignedchar*my_base64(unsignedchar*input,intlength){BIO*bmem,*b64;BUF_MEM*bptr;b64=BIO_new(BIO_f_base64());bmem=BIO_new(BIO_s_mem());b64=BIO_push(b64,bmem);BIO_write(b64,input,length);BIO_flush(b64);BIO_get_mem_ptr(b64,&bptr);unsignedchar*buff=(u

c++ - C/C++ : Converting hexadecimal value in char to integer

我将十六进制值存储为字符:charA='0';charB='6';charC='E';...我需要将它们转换为整数。我知道'atoi',但这只适用于十进制编码的字符值。有类似的功能吗? 最佳答案 intv=(A>'9')?(A&~0x20)-'A'+10:(A-'0');对于ASCII是正确的。对于其他字符集,类似的方法也行得通,但您需要使用toupper而不是&~0x20。 关于c++-C/C++:Convertinghexadecimalvalueinchartointeger,我们

c++ - C2556 : overloaded function differs only by return type

我正在阅读EffectiveC++,它告诉我“可以重载仅因常量不同而不同的成员函数”。书中的例子是:classTextBlock{public:constchar&operator[](std::size_tposition)const;char&operator[](std::size_tposition);private:std::stringtext;}我下面的示例使用了一个存储指针。classA{public:A(int*val):val_(val){}int*get_message(){returnval_;}constint*get_message(){returnval_

C++ 错误 : deduced conflicting types for parameter 'T' string vs const char *

因此,我正在为双端队列容器编写一个简单的模板化搜索函数。这是代码:templatevoidsearchInDequeFor(std::dequeDeque,TsearchValue){for(constauto&element:Deque){if(Deque.empty()){std::cout下面是我在main中调用函数的方式:dequemyDeque={"apple","banana","pear","blueberry"};searchInDequeFor(myDeque,"pear");这是我遇到的错误:candidatetemplateignored:deducedconfl

c++ - std::map::size_type 对于 std::map 其 value_type 是它自己的 size_type

我有一个std::map,float>这占用了太多内存,为了使用更少的内存,我决定将唯一字符串映射到整数(例如std::map,其中每个新的唯一字符串都映射到map的当前size()),并将这些整数值用作映射的成对键(例如,std::map,float>)。而不是int,我想用std::map::size_type:usingmap_index=std::map::size_type;std::pairkey;当然,这不会编译,因为我需要为map提供参数列表:vector.cc:14:19:error:invaliduseoftemplate-name`std::map'without

解决方案:Python中解决“TypeError: Object of type ‘datetime‘ is not JSON serializable”错误

解决方案:Python中解决“TypeError:Objectoftype‘datetime’isnotJSONserializable”错误在Python编程中,经常会使用JSON(JavaScriptObjectNotation)格式来序列化和反序列化数据。然而,当我们尝试将包含datetime对象的数据转换为JSON字符串时,可能会遇到一个常见的错误:“TypeError:Objectoftype‘datetime’isnotJSONserializable”(类型错误:无法将datetime对象转换为JSON可序列化对象)。这个错误的原因是datetime对象不是JSON可序列化的,因

c++ - 为什么写 func( const Class &value ) 更可取?

为什么要使用func(constClass&value)而不仅仅是func(Classvalue)?现代编译器肯定会使用任何一种语法来做最有效的事情。这是否仍然是必要的,或者只是对非优化编译器时代的保留?补充一下,gcc将为这两种语法生成类似的汇编代码输出。也许其他编译器没有?显然,事实并非如此。我很久以前从一些代码中得到的印象是gcc这样做了,但是实验证明这是错误的。感谢MichaelBurr,他对similarquestion的回答如果在这里给出,将被提名。 最佳答案 2个签名之间有2个较大的语义差异。首先是在类型名称中使用&。

c++ - 为什么 clang++ 报告与 "value stored to ' .. .' during its initialization is never read"的结构化绑定(bind)?

我有以下测试用例:testcase("[room]exits"){auto[center,east,north,south,west]=make_test_rooms();check_eq(center->east(),east);check_eq(center->north(),north);check_eq(center->south(),south);check_eq(center->west(),west+1);}当我编译它时,clang++(clangversion5.0.1(tags/RELEASE_501/final))报告:room.cpp:52:7:note:Valu

c++ - 如何在结构/类中获取有关 "current type"的信息?

是否有可能在struct中获取“当前struct的类型”?例如,我想做这样的事情:structfoobar{intx,y;booloperator==(constTHIS_TYPE&other)const/*WhatshouldIputhereinsteadofTHIS_TYPE?*/{returnx==other.x&&y==other.y;}}我试过这样做:structfoobar{intx,y;templatebooloperator==(constT&t)const{decltype(*this)&other=t;/*Wecanuse`this`here,sowecanget"

C++ 错误 : request for member '...' in 'grmanager' which is of non-class type 'GraphicsManager'

这个问题不太可能帮助任何future的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况有关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visitthehelpcenter.关闭10年前。我的类GraphicsManager出现错误。图形管理器.cpp:#include"C:\Users\ChrisUzzolina\Desktop\obj\include\GraphicsManager.h"#include#includeGraphicsManager::GraphicsManager(intSCREEN_WIDTH,intSCREEN_