Home » U++ Library support » U++ Core » Question about SubRange.
Question about SubRange. [message #49191] |
Thu, 04 January 2018 21:58 |
Novo
Messages: 1358 Registered: December 2006
|
Ultimate Contributor |
|
|
Function SubRange has two overloads below.
template <class C>
auto SubRange(C& c, int pos, int count) -> decltype(SubRange(c.begin() + pos, count))
{
return SubRange(c.begin() + pos, count);
}
template <class C>
auto SubRange(C&& c, int pos, int count) -> decltype(SubRange(c.begin() + pos, count))
{
return SubRange(c.begin() + pos, count);
}
The second one doesn't actually move anything, so, it is just not needed, IMHO.
The first one can always be used instead. And it should look like below. IMHO.
template <class C>
auto SubRange(const C& c, int pos, int count) -> decltype(SubRange(c.begin() + pos, count))
{
return SubRange(c.begin() + pos, count);
}
Method begin() is always const I believe ...
And you can drop this decltype in C++14 ...
Regards,
Novo
|
|
|
Goto Forum:
Current Time: Thu Mar 28 11:59:58 CET 2024
Total time taken to generate the page: 0.01125 seconds
|