more const related fixes in SmartRange
This commit is contained in:
@@ -78,13 +78,13 @@ struct SmartRangeT
|
|||||||
* @param f Functor that is applied to all elements before computing the sum
|
* @param f Functor that is applied to all elements before computing the sum
|
||||||
*/
|
*/
|
||||||
template <typename Functor>
|
template <typename Functor>
|
||||||
auto sum(Functor&& f) -> decltype (f(std::declval<HandleT>()))
|
auto sum(Functor&& f) -> typename std::decay<decltype (f(std::declval<HandleT>()))>::type
|
||||||
{
|
{
|
||||||
auto range = static_cast<const RangeT*>(this);
|
auto range = static_cast<const RangeT*>(this);
|
||||||
auto begin = range->begin();
|
auto begin = range->begin();
|
||||||
auto end = range->end();
|
auto end = range->end();
|
||||||
assert(begin != end);
|
assert(begin != end);
|
||||||
decltype (f(*begin)) sum = f(*begin);
|
typename std::decay<decltype (f(*begin))>::type sum = f(*begin);
|
||||||
auto it = begin;
|
auto it = begin;
|
||||||
++it;
|
++it;
|
||||||
for (; it != end; ++it)
|
for (; it != end; ++it)
|
||||||
@@ -99,13 +99,13 @@ struct SmartRangeT
|
|||||||
* @param f Functor that is applied to all elements before computing the average.
|
* @param f Functor that is applied to all elements before computing the average.
|
||||||
*/
|
*/
|
||||||
template <typename Functor>
|
template <typename Functor>
|
||||||
auto avg(Functor&& f) -> decltype (f(std::declval<HandleT>()))
|
auto avg(Functor&& f) -> typename std::decay<decltype (f(std::declval<HandleT>()))>::type
|
||||||
{
|
{
|
||||||
auto range = static_cast<const RangeT*>(this);
|
auto range = static_cast<const RangeT*>(this);
|
||||||
auto begin = range->begin();
|
auto begin = range->begin();
|
||||||
auto end = range->end();
|
auto end = range->end();
|
||||||
assert(begin != end);
|
assert(begin != end);
|
||||||
decltype (f(*begin)) sum = f(*begin);
|
typename std::decay<decltype (f(*begin))>::type sum = f(*begin);
|
||||||
auto it = begin;
|
auto it = begin;
|
||||||
++it;
|
++it;
|
||||||
int n_elements = 1;
|
int n_elements = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user