Код: Выделить всё
struct shifted_vector
{
size_t offset;
std::vector vec;
};
Я думал, что следующие типы возврата являются неправильными, а Decltype (auto) является правильным. Но более поздняя сбоя моей программы тестирования, а первая - нет. Вероятно, в некоторых случаях более позднее перемещение семантики, но сначала нет. < /P>
Код: Выделить всё
/// Get the vector part of a dense vector (it is the vector itself).
template requires(ForwardDenseVector)
constexpr auto &&vec(T &&v) noexcept { return std::forward(v); } // NEVER decltype(auto)
/// Get the vector part of a shifted vector (it is the \a vec field).
template requires(ShiftedVector)
constexpr auto &&vec(T &&v) noexcept { return std::forward(v).vec; } // NEVER decltype(auto)
Подробнее здесь: https://stackoverflow.com/questions/795 ... cltypeauto
Мобильная версия