GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — lambda/src/view_duplicate.hpp at lambda3 · seqan/lambda

Expand file tree

/

view_duplicate.hpp

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
72 lines (63 loc) · 3.37 KB
/

view_duplicate.hpp

Copy path

File metadata and controls

72 lines (63 loc) · 3.37 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// ==========================================================================
// lambda
// ==========================================================================
// Copyright (c) 2019-2024, Sara Hetzel and MPI für Molekulare Genetik
// Copyright (c) 2016-2020, Knut Reinert and Freie Universität Berlin
// All rights reserved.
//
// This file is part of Lambda.
//
// Lambda is Free Software: you can redistribute it and/or modify it
// under the terms found in the LICENSE[.md|.rst] file distributed
// together with this file.
//
// Lambda is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// ==========================================================================
// view_duplicate.hpp: View that duplicates a range in a range-of-ranges
// ==========================================================================
#pragma once
#include <ranges>
#include <bio/ranges/views/transform_by_pos.hpp>
// Definition of the range adaptor object type for views::duplicate.
struct duplicate_fn
{
template <std::ranges::range urng_t>
constexpr auto operator()(urng_t && urange) const
{
static_assert(bio::ranges::range_dimension_v<urng_t> == 2,
"This adaptor only handles range-of-range (two dimensions) as input.");
static_assert(std::ranges::viewable_range<urng_t>,
"The range parameter to views::duplicate cannot be a temporary of a non-view range.");
static_assert(std::ranges::viewable_range<std::ranges::range_reference_t<urng_t>>,
"The inner range of the range parameter to views::duplicate cannot be a temporary of "
"a non-view range.");
static_assert(std::ranges::sized_range<urng_t>,
"The range parameter to views::duplicate must model std::ranges::sized_range.");
static_assert(std::ranges::sized_range<std::ranges::range_reference_t<urng_t>>,
"The inner range of the range parameter to views::duplicate must model "
"std::ranges::sized_range.");
static_assert(std::ranges::random_access_range<urng_t>,
"The range parameter to views::duplicate must model std::ranges::random_access_range.");
static_assert(std::ranges::random_access_range<std::ranges::range_reference_t<urng_t>>,
"The inner range of the range parameter to views::duplicate must model "
"std::ranges::random_access_range.");
return std::forward<urng_t>(urange) |
bio::views::transform_by_pos([](auto && urange, size_t pos) -> decltype(auto)
{ return urange[(pos - (pos % 2)) / 2]; },
[](auto && urange) { return std::ranges::size(urange) * 2; });
}
template <std::ranges::range urng_t>
constexpr friend auto operator|(urng_t && urange, duplicate_fn const & me)
{
return me(std::forward<urng_t>(urange));
}
};
// A view that duplicates the inner ranges in a range-of-ranges. The output range has twice the size of the input range
// where duplicates appear directly after each other.
namespace views
{
inline constexpr auto duplicate = duplicate_fn{};
} // namespace views
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.