boost

Is a virtual destructor needed for your Interface, if you always store it in a shared_ptr?

瘦欲@ 提交于 2020-08-26 19:57:09
问题 Since boost::/std::shared_ptr have the advantage of type-erasing their deleter, you can do nice things like #include <memory> typedef std::shared_ptr<void> gc_ptr; int main(){ gc_ptr p1 = new int(42); gc_ptr p2 = new float(3.14159); gc_ptr p3 = new char('o'); } And this will correctly delete all pointer thanks to the correct deleter being saved. If you ensure that every implementation of your interface always gets created with shared_ptr<Interface> (or make_shared<Interface> ), do you

Is a virtual destructor needed for your Interface, if you always store it in a shared_ptr?

时间秒杀一切 提交于 2020-08-26 19:54:32
问题 Since boost::/std::shared_ptr have the advantage of type-erasing their deleter, you can do nice things like #include <memory> typedef std::shared_ptr<void> gc_ptr; int main(){ gc_ptr p1 = new int(42); gc_ptr p2 = new float(3.14159); gc_ptr p3 = new char('o'); } And this will correctly delete all pointer thanks to the correct deleter being saved. If you ensure that every implementation of your interface always gets created with shared_ptr<Interface> (or make_shared<Interface> ), do you

attempted relative import beyond top-level package with boost/Python

南楼画角 提交于 2020-08-11 01:14:07
问题 I've tried multiple ways to import a module in a post here, but I decided to post a new question since that post was about boost not being able to find the module. Here's the structure of the folder: project |__ utilities | |__ foo.py | |__ boost_extensions | |__ myclass.cpp | |__ myclass.so | |__ someotherstuff | |__ bar.py | |__ mylib.py | |__ __main__.py in foo.py, I have some code that imports from mylib.py: from ..mylib import MyLib class Foo: # code in myclass.cpp, I could not find a