重载三元?:运算符,或更改为包含文件中的{} else {} [英] Overload ternary ?: operator, or change to if{}else{} in included files

查看:94
本文介绍了重载三元?:运算符,或更改为包含文件中的{} else {}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里的研究项目。在我的C ++库中,我包含C文件:

Research project here. In my C++ library, I am including C files:

#include "aprogram.c"

我通过重载(几乎)所有运算符来执行符号。

which I execute symbolically by overloading (almost) all operators.

我有能够检测(条件)?这个:那个并提取条件这个那个用于我的符号执行库。但是, SO 1 ,< a href =https://stackoverflow.com/questions/2874589/unoverloadable-c-operators/2874641#2874641> SO 2 和 SO 3 等已经帮助我意识到?:不能超载。

I have to be able to detect (condition) ? this : that and extract condition, this and that for usage in my symbolic execution library. However, SO 1, SO 2 and SO 3 amongst others already helped me realise that ?: cannot be overloaded.


  • 我有什么方法强行超载?:无论如何?

  • 我可以将包含的C文件中的所有?:语句更改为ifelse语句而不实际更改文件吗?

  • Is there any way for me to forcibly overload ?: anyways?
  • Can I change all ?: statements in my included C file into ifelse-statements without actually changing the file?

推荐答案

根据C ++标准,你不允许重载?:
你能做的最好就是使用C宏(但这可能导致可怕的代码)。

According to the C++ standard you are not permitted to overload ?: The best you can do is use C macros (but this can lead to horrible code).

这篇关于重载三元?:运算符,或更改为包含文件中的{} else {}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆