Subversion Repositories Games.Descent

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 pmbaty 1
/*
2
 * This file is part of the DXX-Rebirth project <https://www.dxx-rebirth.com/>.
3
 * It is copyright by its individual contributors, as recorded in the
4
 * project's Git history.  See COPYING.txt at the top level for license
5
 * terms and a link to the Git history.
6
 */
7
#pragma once
8
 
9
#include <iterator>
10
#include <utility>
11
#include "partial_range.h"
12
 
13
template <typename result_type, typename iterator_type>
14
class iterator_result_converter : public iterator_type
15
{
16
public:
17
        iterator_result_converter(iterator_type &&iter) :
18
                iterator_type(std::move(iter))
19
        {
20
        }
21
        iterator_type base() const
22
        {
23
                return *this;
24
        }
25
        result_type operator*() const
26
        {
27
                return this->iterator_type::operator*();
28
        }
29
        iterator_result_converter &operator++()
30
        {
31
                return static_cast<iterator_result_converter &>(this->iterator_type::operator++());
32
        }
33
};
34
 
35
template <typename result_type, typename range_type, typename iterator_type = iterator_result_converter<result_type, decltype(std::begin(std::declval<range_type &>()))>>
36
static inline partial_range_t<iterator_type> cast_range_result(range_type &range)
37
{
38
        return range;
39
}