[Development] Passing QSize, QPoint, QTime and other small structs by value

Thiago Macieira thiago.macieira at intel.com
Tue Apr 11 07:36:52 CEST 2017

Em segunda-feira, 10 de abril de 2017, às 13:27:05 PDT, Matthew Woehlke 
> Option 2: Teach C++ to choose automatically if such types should be
> passed by value or by const-reference.

That's what I did to QVector.

    typedef typename std::conditional<std::is_fundamental<T>::value || 
std::is_pointer<T>::value, T, const T &>::type parameter_type;

    value_type value(int i, parameter_type defaultValue) const Q_DECL_NOEXCEPT
    { return size_t(i) < d->size ? at(i) : defaultValue; }

Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

More information about the Development mailing list