C ++中的命名空间别名

编程入门 行业动态 更新时间:2024-10-22 22:57:03
本文介绍了C ++中的命名空间别名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用c ++ 11,而我需要c ++ 17库中的一些类.使用从中添加了类的boost时,我希望执行以下操作:

I use c++11 while I need some classes from c++17 library. When using boost from which classes were added I wish to do the following:

#if __cplusplus < CPP17 using std::any = boost::any; #endif

不允许使用此类别名.扩展标准命名空间也会导致不确定的行为.我希望我的代码看起来与C ++版本相同.有没有明确的方法?

Such alias is not allowed. Also extending the std namespace causes undefined behaviour. I wish my code to look the same regardles of the c++ version. Is there a clear way?

推荐答案

明确的方法是为其添加自定义名称.

The clear way is to add a customized name for it.

#if __cplusplus < CPP17 using my_any = boost::any; #else using my_any = std::any; #endif // using my_any...

更多推荐

C ++中的命名空间别名

本文发布于:2023-11-09 05:57:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1571564.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:别名   空间

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!