草庐IT

has-scope

全部标签

c++ - 警告 : statement has no effect (C++)

我有以下代码:voidCScriptTable::EnumReferences(asIScriptEngine*engine){if(m_table){//Callthegcenumcallbackforeachnestedtablesize_tcol=0,row=0,num_cols=m_table->numCols(),num_rows=m_table->numRows();for(col;colgetColType(col)==COL_TABLE){for(row;rowgetTable(row,col);engine->GCEnumCallback(tbl);}}}}}编译(g

c++ - 为什么我不能从函数返回 Boost::Scoped_ptr?

所以我尝试围绕boost.extension函数创建一些包装器来创建类。所以我创建了一个函数:templateboost::scoped_ptrget_class(shared_library&lib,std::stringclass_name,ConstructorTypevalue){map>lib_factories=get_factories(lib);returnboost::scoped_ptrlib_class(lib_factories[class_name].create(value));}调用:templatemap>get_factories(shared_lib

c++ - 重载 << 运算符错误 C2804 : binary 'operator <<' has too many parameters

这是我的类(class):#ifndefCLOCK_H#defineCLOCK_Husingnamespacestd;classClock{//MemberVariablesprivate:inthours,minutes;voidfixTime();public://Getter&settormethods.voidsetHours(inthrs);intgetHours()const;voidsetMinutes(intmins);intgetMinutes()const;//ConstructorsClock();Clock(int);Clock(int,int);//CopyC

已解决AttributeError: ‘str‘ object has no attribute ‘read‘

已解决(json.load()读取json文件报错)AttributeError:‘str‘objecthasnoattribute‘read‘文章目录报错代码报错翻译报错原因解决方法千人全栈VIP答疑群联系博主帮忙解决报错报错代码粉丝群里面的一个粉丝在用Python读取json文件的时候,出现了报错(跑来找我求助,然后顺利帮助他解决了,顺便记录一下希望可以帮助到更多遇到这个bug不会解决的小伙伴),报错信息和代码如下:withzfile.open(name,mode='r')asjson_file:print(json_file,type(json_file))json_bytes=str(

c++ - C++ 错误 : class has no member named

我有这个问题MemoryBundleStorage.cpp:Inmemberfunction'virtualvoiddtn::storage::MemoryBundleStorage::store(constdtn::data::Bundle&)':MemoryBundleStorage.cpp:146:67:error:'constclassdtn::data::Bundle'hasnomembernamed'getClass'MemoryBundleStorage.cpp:150:19:error:'constclassdtn::data::Bundle'hasnomemberna

c++ - `unique_lock`、 `scoped_lock` 和 `lock_guard` 中指定的 mutex_type 的用例是什么?

用于保护std::mutex的c++11mutexRAII类型都有一个typedef:typedefMutexmutex_type;std::lock_guard::mutex_typestd::unique_lock::mutex_typestd::scoped_lock::mutex_type这个成员typedef有什么意义?起初我认为它可以用来概括创建一个对象来移动锁(在unique_lock的情况下)例如:templatevoidfunction(SomeLockin)SomeLock::mutex_typenewMutex;//Dosomething但我无法想象它的用途。需要

c++ - Qt "The program has unexpectedly finished."关闭

我有一个关于QML2(Qt5.2.1)的项目。似乎可以正常工作。但是当我在QtCreator的“应用程序输出”(底部的那个东西)中关闭正在运行的项目(ALT+F4或其他)时,在1-2秒,我收到以下消息:Theprogramhasunexpectedlyfinished.bla-bla-bla.execrashed这发生在发布和Debug模式中。我在调试下启动,但没有收到任何错误。我从最后一个析构函数开始一步一步地进行,直到返回1的returnapp.exec();。我的意思是除了这个-我没有看到任何错误。我应该为此担心吗?我可以知道此消息的原因吗?有没有办法获得更具体的消息?我尝试从c

c++ - std::scoped_allocator_adaptor 和一个使用 std::allocator_arg_t 构造函数的类

我在这里找到了一些词http://en.cppreference.com/w/cpp/memory/scoped_allocator_adaptor/constructifstd::uses_allocator::value==true(thetypeTusesallocators,e.g.itisacontainer)andifstd::is_constructible::value==true,thencallsstd::allocator_traits::construct(OUTERMOST(*this),p,std::allocator_arg,inner_allocator

C++ 错误 : was not declared in this scope with private after public

试图修改来自thispage的代码.问题代码如下:#include#includetemplateclassconst_reverse_wrapper{public:const_reverse_wrapper(constT&cont):container_(cont){}decltype(container_.rbegin())begin()const{returncontainer_.rbegin();}decltype(container_.rend())end(){returncontainer_.rend();}private:constT&container_;};templ

c++ - has_type 模板为 struct type {} 返回 true;

有很多方法可以实现has_type推导ifT的模板有一个名为type的嵌套类或typedef.即namespacedetail{templatestructtovoid{typedefvoidtype;};}templatestructhas_type:std::false_type{};//thisonewillonlybeselectedifC::typeisvalidtemplatestructhas_type::type>:std::true_type{};或者templatechartest_for_type(...){return'0';}templatedoubletes