And exceptions come with their own set of issues: you need to document the
set of exceptions that can be triggered by any function (which includes the
transitive set of all the called functions inside a function...) and
propagation usually doesn't mean much (at some point you reach a level that
cannot do much more than just catch everything and exit (or worse, ignore).

Note that using a return value also ensures destruction of already acquired
resources and also has zero overhead.


On Sun, May 25, 2014 at 9:41 PM, galop1n <notifications@github.com> wrote:

> In Contributing.md:
>
> > +    inline void Clamp(T& val, const T& min, const T& max)
> > +    {
> > +        if (val < min)
> > +            val = min;
> > +        else if (val > max)
> > +            val = max;
> > +    }
> > +    ```
> > +
> > +    Example call: `Clamp(var, 1000, 5000);`
> > +
> > +  - What to do:
> > +
> > +    ```c++
> > +    template<class T>
> > +    inline void Clamp(T* val, const T& min, const T& max)
>
> I would say that c++ have exception for error handling, with the x64 ABI,
> that's does not dirty the generated code as it would before. Under normal
> operation, that's zero overhead and in case of errors, RAII secure
> destruction of already acquired resources.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/dolphin-emu/dolphin/pull/410/files#r13032467>
> .
>



-- 
Pierre "delroth" Bourdon <delroth@gmail.com>
Software Engineer @ Zürich, Switzerland
http://code.delroth.net/