草庐IT

unique_future

全部标签

c++ - 什么是 C++17 等价于 boost::filesystem::unique_path()?

C++17上的std::filesystem和许多C++17之前的编译器的std::experimental::filesystem均基于boost::filesystem并且几乎所有这些都可以移植到较新的std。但我没有看到与boost::filesystem::unique_path()等效的std::filesystem。在std中是否有我没有注意到的等价物?或者有没有推荐的方法来模仿实现?当我的代码注意到它在支持std::filesystem和的平台上编译时,我真的希望替换boost::filesystem依赖项unique_path()是我的转换中唯一不明显的部分。

c++ - 将带有自定义删除器的 unique_ptr 移动到 shared_ptr

我有一个函数可以创建一个带有自定义删除器的unique_ptr并返回它:autogive_unique_ptr(){autodeleter=[](int*pi){deletepi;};int*i=newint{1234};returnstd::unique_ptr(i,deleter);}在该函数的客户端代码中,我想将unique_ptr移动到shared_ptr中,但鉴于我不知道该怎么做在函数之外不知道我的自定义删除器的decltype。我猜它应该是这样的:autouniquePtr=give_unique_ptr();autosharedPtr=std::shared_ptr(st

c++ - 将带有自定义删除器的 unique_ptr 移动到 shared_ptr

我有一个函数可以创建一个带有自定义删除器的unique_ptr并返回它:autogive_unique_ptr(){autodeleter=[](int*pi){deletepi;};int*i=newint{1234};returnstd::unique_ptr(i,deleter);}在该函数的客户端代码中,我想将unique_ptr移动到shared_ptr中,但鉴于我不知道该怎么做在函数之外不知道我的自定义删除器的decltype。我猜它应该是这样的:autouniquePtr=give_unique_ptr();autosharedPtr=std::shared_ptr(st

c++ - Valgrind 在 std::make_unique 中显示内存泄漏

我正在使用Valgrind检查内存泄漏。不幸的是,我收到了Leak_DefinitelyLost警告。附件是我的代码的简化版本,它重现了错误:#include#include#include#includeusingnamespacestd;classBase{public:explicitBase(doublea){a_=a;}virtualvoidfun()=0;protected:doublea_;};classDerived_A:publicBase{public:Derived_A(doublea,vectorb,vectorc):Base(a),b_{b},c_{c}{}v

c++ - Valgrind 在 std::make_unique 中显示内存泄漏

我正在使用Valgrind检查内存泄漏。不幸的是,我收到了Leak_DefinitelyLost警告。附件是我的代码的简化版本,它重现了错误:#include#include#include#includeusingnamespacestd;classBase{public:explicitBase(doublea){a_=a;}virtualvoidfun()=0;protected:doublea_;};classDerived_A:publicBase{public:Derived_A(doublea,vectorb,vectorc):Base(a),b_{b},c_{c}{}v

c++ - 在 std::move() 之后 unique_ptr 会发生什么?

这段代码就是我想做的:Tony&Movie::addTony(){Tony*newTony=newTony;std::unique_ptrtony(newTony);attachActor(std::move(tony));return*newTony;}我想知道我是否可以这样做:Tony&Movie::addTony(){std::unique_ptrtony(newTony);attachActor(std::move(tony));return*tony.get();}但是*tony.get()会是同一个指针还是null?我知道我可以验证,但它的标准做法是什么?

c++ - 在 std::move() 之后 unique_ptr 会发生什么?

这段代码就是我想做的:Tony&Movie::addTony(){Tony*newTony=newTony;std::unique_ptrtony(newTony);attachActor(std::move(tony));return*newTony;}我想知道我是否可以这样做:Tony&Movie::addTony(){std::unique_ptrtony(newTony);attachActor(std::move(tony));return*tony.get();}但是*tony.get()会是同一个指针还是null?我知道我可以验证,但它的标准做法是什么?

如何理解此表达式:“ future_to_url = {executor.submit(load_url,url,60):url for url for url”

当我在官方文件中时,请参阅此示例:urls=['http://www.foxnews.com/','http://www.cnn.com/','http://europe.wsj.com/','http://www.bbc.co.uk/','http://some-made-up-domain.com/']defload_url(url,timeout):withurllib.request.urlopen(url,timeout=timeout)asconn:returnconn.read()withconcurrent.futures.ThreadPoolExecutor(max_work

python - 自定义 unique_together 键名

我有一个带有unique_together的模型定义为3个字段一起唯一:classMyModel(models.Model):clid=models.AutoField(primary_key=True,db_column='CLID')csid=models.IntegerField(db_column='CSID')cid=models.IntegerField(db_column='CID')uuid=models.CharField(max_length=96,db_column='UUID',blank=True)classMeta(models.Meta):unique_t

python - 自定义 unique_together 键名

我有一个带有unique_together的模型定义为3个字段一起唯一:classMyModel(models.Model):clid=models.AutoField(primary_key=True,db_column='CLID')csid=models.IntegerField(db_column='CSID')cid=models.IntegerField(db_column='CID')uuid=models.CharField(max_length=96,db_column='UUID',blank=True)classMeta(models.Meta):unique_t