[Development] Proposal: adding Q_DECL_NOEXCEPT to many methods

Marc Mutz marc.mutz at kdab.com
Thu Aug 2 23:57:58 CEST 2012


On Thursday August 2 2012, Thiago Macieira wrote:
> On quinta-feira, 2 de agosto de 2012 16.02.43, Marc Mutz wrote:
[....]
> By the way, I'm running into an issue which I'm not entirely sure whether
> it's a design issue. Imagine this case:
>
> class Object
> {
>     void f();
>     void g() noexcept(same noexcept status as f);
> };
>
> That is, I want to declare g to be as noexcept as its sibling function f.
> How? All of these options fail:
>
> noexcept(noexcept(f))
>  -> evaluates to true
> noexcept(noexcept(Object::f))
>  -> error: invalid use of non-static member function ‘void Object::f()'
> noexcept(noexcept(f()))
>  -> error: cannot call member function ‘void Object::f()’ without object
> noexcept(noexcept(this->f()))
>  -> error: invalid use of ‘this’ at top level
> noexcept(noexcept(Object().f()))
>  -> error: invalid use of incomplete type ‘struct Object’
>
> Any suggestions?

noexcept(std::declval<Object>().f()) should work.

-- 
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
www.kdab.com || Germany +49-30-521325470 || Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-Independent Software Solutions



More information about the Development mailing list