I have to interface with some C code from C++ class constructor (Intel library)
class A{
A{
x = ippiMalloc();
if(x==NULL) ...
}
}
In the constructor malloc function (intel version) is used. If ippiMalloc function do not succeed what is the correct way to handle it. Throw exception?
Yes, an exception would likely be the most appropriate way to handle the error here -- at least it would be the cleanest way. This is also what the "new" operator would do on failure.
If your app isn't exception aware than you have a problem. In which case a factory method on the class might make sense.
static A * create() { ... }
Here you can wrap this into a non-exception program, likely returning null if you can't create the object.
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