U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » U++ Core » Question about SubRange.
Question about SubRange. [message #49191] Thu, 04 January 2018 21:58 Go to previous message
Novo is currently offline  Novo
Messages: 1431
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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: ReadSecret() function for reading passwords, etc. from the console.
Next Topic: I've been using FindFile wrong all these years
Goto Forum:
  


Current Time: Tue May 05 11:41:44 GMT+2 2026

Total time taken to generate the page: 0.00435 seconds