草庐IT

Unique_ptr

全部标签

SQLite 完整性错误 : UNIQUE constraint failed:

我刚收到一个奇怪的错误:IntegrityError:UNIQUEconstraintfailed:jumptimes.player_id,jumptimes.map_id,jumptimes.runID我的SQL查询:t=(playerid,mapid,timeTaken,(time()ifnotdateOverwriteelsedateOverwrite),runID,runLeaveZoneVelocity,EnterZoneVelocity,averageVelocity,time())log("PlayerID:%s|mapid:%s|timeTaken:%s|Date:%s

c++ - tr1::shared_ptr 和 boost::shared_ptr 的区别?

tr1::shared_ptr和boost::shared_ptr有什么区别吗?如果有,是什么? 最佳答案 不,boostshared_ptr的文档说:ThisimplementationconformstotheTR1specification,withtheonlyexceptionthatitresidesinnamespaceboostinsteadofstd::tr1. 关于c++-tr1::shared_ptr和boost::shared_ptr的区别?,我们在StackOv

ruby-on-rails - rails : three most recent comments with unique users

我应该在命名范围:by_unique_users中放入什么,以便我可以执行Comment.recent.by_unique_users.limit(3),并且每个用户只获得一个评论?classUserhas_many:commentsendclassCommentbelongs_to:usernamed_scope:recent,:order=>'comments.created_atDESC'named_scope:limit,lambda{|limit|{:limit=>limit}}named_scope:by_unique_usersend在sqlitenamed_scope上

ruby-on-rails - 我如何解决 Rails 中的 "index unique_schema_migrations already exists"?

运行rakedb:migrate然后运行​​raketest:units产生以下结果:raketest:functionals(in/projects/my_project)rakeaborted!SQLite3::SQLException:indexunique_schema_migrationsalreadyexists:CREATEUNIQUEINDEX"unique_schema_migrations"ON"ts_schema_migrations"("version")db/schema.rb相关部分如下:create_table"ts_schema_migrations",

xml - XSD:如何将 'unique' 和 'key'/'keyref' 与元素值一起使用?

我尝试使用和/具有元素值,但我无法让它工作。如果我用attrubute值来做,它就像一个魅力。测试.xmlrole1role2role2role1role1role3我想确保roles只被定义一次并且在action元素下定义的roles只是那些在上层定义的.测试.xsd验证失败并显示以下消息:DescriptionResourcePathLocationTypecvc-identity-constraint.3:Field"./test:role"ofidentityconstraint"keyrefRole"matchesmorethanonevaluewithinthescopeo

php - 使用 SWIG 在 PHP 中包装 boost::shared_ptr

如果我使用SWIG包装这个C++函数:boost::shared_ptrClient::create(){returnboost::shared_ptr(newClient());}然后在PHP中调用它:$client=Client::create();echogettype($client);$client的类型是resource,不是object,所以我不能调用Client方法。包装此功能的选项有哪些?我正在为其他人的C++库创建一个PHP包装器,因此重新编写代码以不使用boost::shared_ptr并不是一个真正的选择。这是迄今为止我想出的唯一解决方案:MyClientCli

c++ - std::shared_ptr 什么时候释放它的对象?

我在使用GCC4.8.4的Ubuntu14.04上,我的代码类似于以下内容:std::shared_ptrmy_shared_object=setelsewhere...MyFunction(*my_shared_object);MyFunction的签名如下所示:voidMyFunction(constMyClass&my_object)可以找到完整的代码here但是,我发现my_object实际上超出了MyFunction上下文中的范围。我的想法是my_shared_object只有在超出范围后才会释放其内容,这意味着在MyFunction返回之后。我不确定我是否误解了std::s

c++ - 将派生类的 unique_ptr 添加到基类 unique_ptr 的 vector 中

关闭。这个问题需要detailsorclarity.它目前不接受答案。想改进这个问题吗?通过editingthispost添加细节并澄清问题.关闭6年前。Improvethisquestion我有一个std::unique_ptr我想添加到std::vector>.std::unique_ptrderivedObject;std::vector>vec;vec.push_back(derivedObject)//Invalidarguments

c++ - 这是对 unique_ptr 的误用吗?

我正在转向智能指针,并努力确保正确使用它们。有很多问题涵盖了何时使用每个问题,但我找不到专门关于getter的问题。我有一个拥有指针的类,我希望其他类能够访问该指针(逐步重构遗留代码)。我想给这个类一个unique_ptr因为它只会拥有那个对象,但它们不能被复制。我应该返回对unique_ptr的引用,还是只使用shared_ptr?classB{public:doAction(){};};classA{private:std::unqiue_ptrpointer;public:std::unique_ptr&GetPointer(){returnpointer;}};a.GetPoi

c++ - 制作 shared_ptr 的拷贝时会发生什么?

我想了解当将shared_ptr分配给另一个时,shared_ptr中托管对象的引用计数会受到怎样的影响。我在C++primer,5thedition中看到以下声明:Forexample,thecounterassociatedwithashared_ptrisincrementedwhen...weuseitastheright-handoperandofanassignment...Thecounterisdecrementedwhenweassignanewvaluetotheshared_ptr...举个例子:autop=make_shared(42);//objecttowh