On quinta-feira, 2 de agosto de 2012 16.02.43, Marc Mutz wrote: > Need to be careful with templates. Can't use add the unrestricted noexcept > there, need to use noexcept(noexcept(expr)), which is even uglier
template<typename T> inline uint qHash(const T &t, uint seed) Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(t))) { return (qHash(t) ^ seed); } template <typename T1, typename T2> inline uint qHash(const QPair<T1, T2> &key, uint seed = 0) Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(key.first, seed)) && noexcept(qHash(key.second, seed))) { ... } 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? My actual use-case is of a function declared in a base-class: I want QMutex::lock() to be noexcept if QBasicMutex::lockInternal() is noexcept. In that particular case, it works like this: class QMutex : public QBasicMutex { static QBasicMutex *dummyBasicMutex() noexcept; public: void lock() noexcept(noexcept(dummyBasicMutex()->lockInternal())); }; But it's ugly. -- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Software Architect - Intel Open Source Technology Center PGP/GPG: 0x6EF45358; fingerprint: E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development