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...
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...
Is there any simple way to have an implicit conversion from frames_t to samples_t be marked as an error in C++?
You could go all out and define your own system within boost.units, or alternatively just use the BOOST_STRONG_TYPEDEF
macro to create a strong typedef for each type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With