preventing自动铸件与整数 [英] Preventing automatic casts with integers

查看:116
本文介绍了preventing自动铸件与整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发展(在C ++)的音频应用程序,我有很多的相互调用的函数,任取帧(即1单声道或立体声2浮样本)的数量或原始样本数...

I'm developing an audio application (in C++) and I have lots of functions that call each other that either take the number of frames (i.e. 1 mono or 2 stereo float samples) or the raw number of samples...

这是越来越难以跟踪每个功能(样品或框架?),当由N沟道到MULT或DIV的语义,所以我想以某种方式做一个typedef samples_t和frames_t(为unsigned int)和有编译器帮我...

It is getting harder to keep track of the semantics of each function (samples or frames?) and when to mult or div by nChannels, so I would like to somehow do a typedef samples_t and frames_t (to unsigned int) and have the compiler help me out...

有没有简单的方法来具有frames_t的隐式转换到samples_t被标记为C ++中的错误?

Is there any simple way to have an implicit conversion from frames_t to samples_t be marked as an error in C++?

推荐答案

不,除非frames_t和samples_t实际上是不同的类型。你可以让他们POD结构包含一个整数,但他们typedefing将是无效的。

Not unless frames_t and samples_t are actually different types. You could make them POD structs containing an integer, but typedefing them will have no effect.

这篇关于preventing自动铸件与整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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