Is there a way to use delegating constructors in Visual Studio 2012?

早过忘川 提交于 2020-01-09 11:37:07

问题


Looking through the new features of C++11, delegating constructors seems like they would be particular useful in my situation.

Unfortunately, I need to use Visual Studio. The project I am working on has a several month deadline and using experimental/broken compilers doesn't concern me. Is there a version of Visual C++ that can will let me do constructor delegation?

See http://www.stroustrup.com/C++11FAQ.html#inheriting


回答1:


Yes, there is a beta version of the compiler that supports delegating constructors - the Visual C++ Compiler November 2012 CTP.




回答2:


In the meanwhile, try

#define INHERIT_CONSTRUCTOR(BaseName,DerivedName) template <class... Args> DerivedName(Args&&... args) : BaseName(std::forward<Args>(args)...) { }



回答3:


Once you've successfully installed the CTP via the link given above by Karel Petranek, just create any old C++ project.

Then, under the project's 'Property Pages > Configuration Properties > General > Platform Toolset', choose "Microsoft Visual C++ Compiler Nov 2012 CTP (v120_CTP_Nov2012)".

That's all. Now you have access to these additional C++ compiler features in VS2012.




回答4:


You don't have to install CTP anymore.
Visual Studio 2013 will support delegating constructors and you can try the Preview version which is available by now.



来源:https://stackoverflow.com/questions/14432802/is-there-a-way-to-use-delegating-constructors-in-visual-studio-2012

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!