C++14 and later CRTP templates for defining iterators, views, and containers
An updated C++20-friendly version of the iterator_facade
and
iterator_adaptor
parts of Boost.Iterator (now called iterator_interface
);
a pre-C++20 version of C++20's view_interface
; and a new template called
container_interface
, meant to aid the creation of new containers; all
targeting standardization. This library requires at least C++14.
For the iterator portion -- if you need to write an iterator, iterator_interface
turns this:
struct repeated_chars_iterator
{
using value_type = char;
using difference_type = std::ptrdiff_t;
using pointer = char const *;
using reference = char const;
using iterator_category = std::random_access_iterator_tag;
constexpr repeated_chars_iterator() noexcept :
first_(nullptr),
size_(0),
n_(0)
{}
constexpr repeated_chars_iterator(
char const * first,
difference_type size,
difference_type n) noexcept :
first_(first),
size_(size),
n_(n)
{}
constexpr reference operator*() const noexcept
{
return first_[n_ % size_];
}
constexpr value_type operator[](difference_type n) const noexcept
{
return first_[(n_ + n) % size_];
}
constexpr repeated_chars_iterator & operator++() noexcept
{
++n_;
return *this;
}
constexpr repeated_chars_iterator operator++(int)noexcept
{
repeated_chars_iterator retval = *this;
++*this;
return retval;
}
constexpr repeated_chars_iterator & operator+=(difference_type n) noexcept
{
n_ += n;
return *this;
}
constexpr repeated_chars_iterator & operator--() noexcept
{
--n_;
return *this;
}
constexpr repeated_chars_iterator operator--(int)noexcept
{
repeated_chars_iterator retval = *this;
--*this;
return retval;
}
constexpr repeated_chars_iterator & operator-=(difference_type n) noexcept
{
n_ -= n;
return *this;
}
friend constexpr bool operator==(
repeated_chars_iterator lhs, repeated_chars_iterator rhs) noexcept
{
return lhs.first_ == rhs.first_ && lhs.n_ == rhs.n_;
}
friend constexpr bool operator!=(
repeated_chars_iterator lhs, repeated_chars_iterator rhs) noexcept
{
return !(lhs == rhs);
}
friend constexpr bool operator<(
repeated_chars_iterator lhs, repeated_chars_iterator rhs) noexcept
{
return lhs.first_ == rhs.first_ && lhs.n_ < rhs.n_;
}
friend constexpr bool operator<=(
repeated_chars_iterator lhs, repeated_chars_iterator rhs) noexcept
{
return lhs == rhs || lhs < rhs;
}
friend constexpr bool operator>(
repeated_chars_iterator lhs, repeated_chars_iterator rhs) noexcept
{
return rhs < lhs;
}
friend constexpr bool operator>=(
repeated_chars_iterator lhs, repeated_chars_iterator rhs) noexcept
{
return rhs <= lhs;
}
friend constexpr repeated_chars_iterator
operator+(repeated_chars_iterator lhs, difference_type rhs) noexcept
{
return lhs += rhs;
}
friend constexpr repeated_chars_iterator
operator+(difference_type lhs, repeated_chars_iterator rhs) noexcept
{
return rhs += lhs;
}
friend constexpr repeated_chars_iterator
operator-(repeated_chars_iterator lhs, difference_type rhs) noexcept
{
return lhs -= rhs;
}
friend constexpr difference_type operator-(
repeated_chars_iterator lhs, repeated_chars_iterator rhs) noexcept
{
return lhs.n_ - rhs.n_;
}
private:
char const * first_;
difference_type size_;
difference_type n_;
};
Depends (2)
Builds
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-clang_16.0_libc++-static_O3 |
timestamp |
2024-04-19 13:49:03 UTC (04:25:35 hours ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-clang_16.0_libc++ |
timestamp |
2024-04-19 13:47:47 UTC (04:26:52 hours ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-clang_16.0_libc++-O3 |
timestamp |
2024-04-19 13:47:37 UTC (04:27:01 hours ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-microsoft-win32-msvc14.3 |
tgt config |
windows_10-clang_16.0_llvm_msvc_17.6-static_O2 |
timestamp |
2024-04-19 13:33:10 UTC (04:41:28 hours ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-microsoft-win32-msvc14.3 |
tgt config |
windows_10-clang_16.0_llvm_msvc_17.6 |
timestamp |
2024-04-19 13:32:47 UTC (04:41:51 hours ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-microsoft-win32-msvc14.3 |
tgt config |
windows_10-clang_16.0_llvm_msvc_17.6-O2 |
timestamp |
2024-04-19 13:32:32 UTC (04:42:06 hours ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-gcc_12-bindist |
timestamp |
2024-04-19 13:28:11 UTC (04:46:27 hours ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-microsoft-win32-msvc14.3 |
tgt config |
windows_10-msvc_17.6-static_O2 |
timestamp |
2024-04-19 12:52:12 UTC (05:22:26 hours ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-microsoft-win32-msvc14.3 |
tgt config |
windows_10-msvc_17.6 |
timestamp |
2024-04-19 12:51:48 UTC (05:22:50 hours ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-microsoft-win32-msvc14.3 |
tgt config |
windows_10-msvc_17.6-O2 |
timestamp |
2024-04-19 12:51:22 UTC (05:23:17 hours ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-w64-mingw32 |
tgt config |
windows_10-gcc_12.2_mingw_w64-static_O2 |
timestamp |
2024-04-19 12:49:02 UTC (05:25:36 hours ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-w64-mingw32 |
tgt config |
windows_10-gcc_12.2_mingw_w64-O2 |
timestamp |
2024-04-19 12:47:10 UTC (05:27:29 hours ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-w64-mingw32 |
tgt config |
windows_10-gcc_12.2_mingw_w64 |
timestamp |
2024-04-19 12:47:02 UTC (05:27:36 hours ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-microsoft-win32-msvc14.3 |
tgt config |
windows_10-msvc_17.5 |
timestamp |
2024-04-19 12:27:23 UTC (05:47:16 hours ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_11-gcc_12.1 |
timestamp |
2024-04-19 12:13:30 UTC (06:01:08 hours ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_12-clang_16 |
timestamp |
2024-04-19 11:01:48 UTC (07:12:51 hours ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_12-clang_16-static_O3 |
timestamp |
2024-04-19 10:55:48 UTC (07:18:50 hours ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_12-clang_16-O3 |
timestamp |
2024-04-19 10:54:31 UTC (07:20:07 hours ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_fedora_38-gcc_13-bindist |
timestamp |
2024-04-19 10:54:23 UTC (07:20:16 hours ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-microsoft-win32-msvc14.3 |
tgt config |
windows_10-clang_15.0_msvc_msvc_17.6 |
timestamp |
2024-04-19 10:50:30 UTC (07:24:09 hours ago) |
result |
warning (update) | warning (test-installed) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-clang_16.0-static_O3 |
timestamp |
2024-04-19 10:35:22 UTC (07:39:16 hours ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-clang_16.0-O3 |
timestamp |
2024-04-19 10:32:50 UTC (07:41:48 hours ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-clang_16.0 |
timestamp |
2024-04-19 10:32:17 UTC (07:42:21 hours ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-freebsd13.2 |
tgt config |
freebsd_13-clang_14.0 |
timestamp |
2024-04-19 10:24:32 UTC (07:50:06 hours ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-freebsd13.2 |
tgt config |
freebsd_13-clang_14.0-static_O3 |
timestamp |
2024-04-19 10:24:29 UTC (07:50:10 hours ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-gcc_13.1-O3 |
timestamp |
2024-04-19 10:24:12 UTC (07:50:27 hours ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-gcc_13.1-static_O3 |
timestamp |
2024-04-19 10:23:58 UTC (07:50:40 hours ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-freebsd13.2 |
tgt config |
freebsd_13-clang_14.0-O3 |
timestamp |
2024-04-19 10:23:47 UTC (07:50:52 hours ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-gcc_13.1-ndebug_O3 |
timestamp |
2024-04-19 10:23:45 UTC (07:50:53 hours ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-gcc_13.1 |
timestamp |
2024-04-19 10:23:35 UTC (07:51:04 hours ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-freebsd12.4 |
tgt config |
freebsd_12-clang_13.0 |
timestamp |
2024-04-19 10:23:20 UTC (07:51:18 hours ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-clang_15.0 |
timestamp |
2024-04-19 10:23:02 UTC (07:51:36 hours ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_debian_12-clang_15.0_libc++ |
timestamp |
2024-04-19 10:23:01 UTC (07:51:37 hours ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-apple-darwin22.5.0 |
tgt config |
macos_13-clang_15.0-static_O3 |
timestamp |
2024-04-19 09:52:53 UTC (08:21:45 hours ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-apple-darwin22.5.0 |
tgt config |
macos_13-clang_15.0-O3 |
timestamp |
2024-04-19 09:52:11 UTC (08:22:27 hours ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-apple-darwin22.5.0 |
tgt config |
macos_13-clang_15.0 |
timestamp |
2024-04-19 09:51:33 UTC (08:23:05 hours ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_11-gcc_12 |
timestamp |
2024-04-17 14:49:32 UTC (02 03:25:06 days ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-apple-darwin22.5.0 |
tgt config |
macos_13-clang_14.0-static_O3 |
timestamp |
2024-04-17 11:11:15 UTC (02 07:03:24 days ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-apple-darwin22.5.0 |
tgt config |
macos_13-clang_14.0-O3 |
timestamp |
2024-04-17 11:10:35 UTC (02 07:04:03 days ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-apple-darwin22.5.0 |
tgt config |
macos_13-clang_14.0 |
timestamp |
2024-04-17 11:09:53 UTC (02 07:04:45 days ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_12-gcc_13-O3 |
timestamp |
2024-04-17 10:33:35 UTC (02 07:41:03 days ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_12-gcc_13-ndebug_O3 |
timestamp |
2024-04-17 10:33:05 UTC (02 07:41:33 days ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_12-gcc_13-static_O3 |
timestamp |
2024-04-17 10:33:05 UTC (02 07:41:34 days ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_12-gcc_13 |
timestamp |
2024-04-17 10:32:32 UTC (02 07:42:06 days ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_12-clang_15_libc++ |
timestamp |
2024-04-17 10:22:34 UTC (02 07:52:04 days ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_12-clang_15 |
timestamp |
2024-04-17 10:21:58 UTC (02 07:52:40 days ago) |
result |
error (update) | log | rebuild |
toolchain |
public-0.16.0 |
target |
x86_64-linux-gnu |
tgt config |
linux_fedora_37-gcc_12.2-bindist |
timestamp |
2024-04-17 00:57:36 UTC (02 17:17:02 days ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_12-clang_16_libc++-static_O3 |
timestamp |
2024-04-16 19:37:27 UTC (02 22:37:11 days ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_12-clang_16_libc++-O3 |
timestamp |
2024-04-16 19:23:53 UTC (02 22:50:46 days ago) |
result |
success | log | rebuild |
toolchain |
public-0.16.0 |
target |
aarch64-linux-gnu |
tgt config |
linux_debian_12-clang_16_libc++ |
timestamp |
2024-04-16 19:18:45 UTC (02 22:55:53 days ago) |
result |
success | log | rebuild |
target |
x86_64-apple-darwin22.5.0 |
tgt config |
macos_13-gcc_13_homebrew |
result |
excluded (https://github) |
target |
x86_64-apple-darwin22.5.0 |
tgt config |
macos_13-gcc_13_homebrew-O3 |
result |
excluded (https://github) |
target |
x86_64-apple-darwin22.5.0 |
tgt config |
macos_13-gcc_13_homebrew-static_O3 |
result |
excluded (https://github) |