CDT  1.4.1
C++ library for constrained Delaunay triangulation
Loading...
Searching...
No Matches
remove_at.hpp
1#ifndef REMOVE_AT_HPP
2#define REMOVE_AT_HPP
3
4// check if c++11 is supported
5#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900)
6#define REMOVE_AT_CXX11_IS_SUPPORTED
7#elif !defined(__cplusplus) && !defined(_MSC_VER)
8typedef char couldnt_parse_cxx_standard[-1];
9#endif
10
11#include <algorithm>
12#include <iterator>
13
18template <class ForwardIt, class SortUniqIndsFwdIt>
19inline ForwardIt remove_at(
20 ForwardIt first,
21 ForwardIt last,
22 SortUniqIndsFwdIt ii_first,
23 SortUniqIndsFwdIt ii_last)
24{
25 if(ii_first == ii_last) // no indices-to-remove are given
26 return last;
27 typedef typename std::iterator_traits<ForwardIt>::difference_type diff_t;
28 typedef typename std::iterator_traits<SortUniqIndsFwdIt>::value_type ind_t;
29 ForwardIt destination = first + static_cast<diff_t>(*ii_first);
30 while(ii_first != ii_last)
31 {
32 // advance to an index after a chunk of elements-to-keep
33 for(ind_t cur = *ii_first++; ii_first != ii_last; ++ii_first)
34 {
35 const ind_t nxt = *ii_first;
36 if(nxt - cur > 1)
37 break;
38 cur = nxt;
39 }
40 // move the chunk of elements-to-keep to new destination
41 const ForwardIt source_first =
42 first + static_cast<diff_t>(*(ii_first - 1)) + 1;
43 const ForwardIt source_last =
44 ii_first != ii_last ? first + static_cast<diff_t>(*ii_first) : last;
45#ifdef REMOVE_AT_CXX11_IS_SUPPORTED
46 std::move(source_first, source_last, destination);
47#else
48 std::copy(source_first, source_last, destination); // c++98 version
49#endif
50 destination += source_last - source_first;
51 }
52 return destination;
53}
54
55#endif // REMOVE_AT_HPP
char couldnt_parse_cxx_standard[-1]
Error: couldn't parse standard.
Definition CDTUtils.h:24