Em segunda-feira, 10 de abril de 2017, às 13:27:05 PDT, Matthew Woehlke 
escreveu:
> 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

_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to