Is there a way to use delegating constructors in V

2019-01-20 10:15发布

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

4条回答
闹够了就滚
2楼-- · 2019-01-20 10:47

In the meanwhile, try

#define INHERIT_CONSTRUCTOR(BaseName,DerivedName) template <class... Args> DerivedName(Args&&... args) : BaseName(std::forward<Args>(args)...) { }
查看更多
三岁会撩人
3楼-- · 2019-01-20 10:49

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.

查看更多
女痞
4楼-- · 2019-01-20 11:00

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.

查看更多
神经病院院长
5楼-- · 2019-01-20 11:04

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

查看更多
登录 后发表回答