Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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: 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
 
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: Thu Mar 28 11:59:58 CET 2024

Total time taken to generate the page: 0.01125 seconds