Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/tutorial/05_ranges/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ remaining (even) values, i.e.
std::vector vec{1, 2, 3, 4, 5, 6};
auto v = vec | // ...?

std::cout << *v.begin() << '\n'; // should print 4
std::cout << v.front() << '\n'; // should print 4
```
\endassignment
\solution
Expand Down
6 changes: 3 additions & 3 deletions doc/tutorial/05_ranges/range_snippets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ int main()
//![rev_def]
//![def]

std::cout << *v.begin() << '\n';
std::cout << v.front() << '\n';
//![all]
}

Expand All @@ -27,9 +27,9 @@ int main()
std::vector vec{1, 2, 3, 4, 5, 6};
auto v = vec | std::views::reverse | std::views::drop(2);

std::cout << *v.begin() << '\n';
std::cout << v.front() << '\n';
//![piped]
*v.begin() = 42; // now vec == {1, 2, 3, 42, 5, 6 } !!
v.front() = 42; // now vec == {1, 2, 3, 42, 5, 6 } !!
//![assign_through]
}
}
2 changes: 1 addition & 1 deletion doc/tutorial/05_ranges/range_solution1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ int main()
return i * i;
});

std::cout << *v.begin() << '\n'; // prints 4
std::cout << v.front() << '\n'; // prints 4
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ int main()
seqan3::sequence_file_input fin{std::filesystem::current_path() / "my.fastq"};
using record_type = typename decltype(fin)::record_type;

record_type rec = std::move(*fin.begin()); // avoid copying
record_type rec = std::move(fin.front()); // avoid copying
}
//![main]
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ int main()
using record_type = typename decltype(fin)::record_type;

// Because `fin` is a range, we can access the first element by dereferencing fin.begin()
record_type rec = *fin.begin();
record_type rec = fin.front();
}
//![main]
4 changes: 2 additions & 2 deletions include/seqan3/utility/views/repeat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,13 @@ class repeat_view : public std::ranges::view_interface<repeat_view<value_t>>
*/
constexpr const_reference operator[](difference_type const SEQAN3_DOXYGEN_ONLY(n)) const noexcept
{
return *single_value.begin();
return single_value.front();
}

//!\copydoc operator[]()
constexpr reference operator[](difference_type const SEQAN3_DOXYGEN_ONLY(n)) noexcept
{
return *single_value.begin();
return single_value.front();
}
//!}

Expand Down
6 changes: 3 additions & 3 deletions test/include/seqan3/test/range/container_test_template.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ TYPED_TEST_P(container_over_dna4_test, iterators)
TypeParam const t2{'A'_dna4, 'C'_dna4, 'C'_dna4, 'G'_dna4, 'T'_dna4};

// begin
EXPECT_EQ(*t1.begin(), 'A'_dna4);
EXPECT_EQ(t1.front(), 'A'_dna4);
EXPECT_EQ(*t1.cbegin(), 'A'_dna4);
EXPECT_EQ(*t2.begin(), 'A'_dna4);
EXPECT_EQ(t2.front(), 'A'_dna4);
EXPECT_EQ(*t2.cbegin(), 'A'_dna4);

// end and arithmetic
Expand All @@ -117,7 +117,7 @@ TYPED_TEST_P(container_over_dna4_test, iterators)
EXPECT_TRUE(t1.cend() == t1.end());

// mutability
*t1.begin() = 'T'_dna4;
t1.front() = 'T'_dna4;
EXPECT_RANGE_EQ(t1, "TCCGT"_dna4);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct iterator_fixture<outer_iterator> : alignment_matrix_base_test<test_type>
template <typename lhs_t, typename rhs_t>
static void expect_eq(lhs_t lhs, rhs_t rhs)
{
EXPECT_EQ((*lhs.begin()).current, rhs);
EXPECT_EQ(lhs.front().current, rhs);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct iterator_fixture<outer_iterator> : alignment_matrix_base_test<test_type>
template <typename lhs_t, typename rhs_t>
static void expect_eq(lhs_t lhs, rhs_t rhs)
{
EXPECT_EQ((*lhs.begin()).current, rhs);
EXPECT_EQ(lhs.front().current, rhs);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct iterator_fixture<outer_iterator<test_type>> : alignment_matrix_base_test<
template <typename lhs_t, typename rhs_t>
static void expect_eq(lhs_t lhs, rhs_t rhs)
{
test(*lhs.begin(), rhs);
test(lhs.front(), rhs);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct iterator_fixture<outer_iterator<test_type>> : alignment_matrix_base_test<
template <typename lhs_t, typename rhs_t>
static void expect_eq(lhs_t lhs, rhs_t rhs)
{
test(*lhs.begin(), rhs);
test(lhs.front(), rhs);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ auto run_test(config_t const & cfg)
using alignment_result_t = typename traits_t::alignment_result_type;

alignment_result_t align_result{};
algorithm(*indexed_sequence_pairs.begin(),
algorithm(indexed_sequence_pairs.front(),
[&](auto && res) mutable
{
align_result = std::forward<decltype(res)>(res);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/alphabet/container/bitpacked_sequence_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ TEST(bitpacked_sequence_test, issue1743_complement_on_proxy)
{
seqan3::bitpacked_sequence<seqan3::dna4> v{'A'_dna4};

auto proxy = *v.begin();
auto proxy = v.front();
auto complement = seqan3::complement(proxy);

EXPECT_SAME_TYPE(decltype(complement), seqan3::dna4);
Expand Down
8 changes: 4 additions & 4 deletions test/unit/alphabet/container/container_of_container_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ TYPED_TEST(container_of_container, iterators)
TypeParam const t2{"ACGT"_dna4, "ACGT"_dna4, "GAGGA"_dna4};

// begin
EXPECT_RANGE_EQ(*t1.begin(), "ACGT"_dna4);
EXPECT_RANGE_EQ(t1.front(), "ACGT"_dna4);
EXPECT_RANGE_EQ(*t1.cbegin(), "ACGT"_dna4);
EXPECT_RANGE_EQ(*t2.begin(), "ACGT"_dna4);
EXPECT_RANGE_EQ(t2.front(), "ACGT"_dna4);
EXPECT_RANGE_EQ(*t2.cbegin(), "ACGT"_dna4);

// end and arithmetic
Expand All @@ -111,8 +111,8 @@ TYPED_TEST(container_of_container, iterators)
EXPECT_TRUE(t1.cend() == t1.end());

// writability
(*t1.begin())[0] = 'T'_dna4;
EXPECT_RANGE_EQ(*t1.begin(), "TCGT"_dna4);
t1.front()[0] = 'T'_dna4;
EXPECT_RANGE_EQ(t1.front(), "TCGT"_dna4);
}

TYPED_TEST(container_of_container, element_access)
Expand Down
4 changes: 2 additions & 2 deletions test/unit/io/sam_file/format_bam_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,8 @@ TEST_F(bam_format, too_long_cigar_string_read)

seqan3::sam_file_input fin{stream, this->ref_ids, this->ref_sequences, seqan3::format_bam{}};

EXPECT_RANGE_EQ((*fin.begin()).cigar_sequence(), this->cigars[0]);
EXPECT_EQ((*fin.begin()).tags().size(), 0u); // redundant CG tag is removed
EXPECT_RANGE_EQ(fin.front().cigar_sequence(), this->cigars[0]);
EXPECT_EQ(fin.front().tags().size(), 0u); // redundant CG tag is removed
}

{ // error: sam_tag_dictionary is not read
Expand Down
12 changes: 6 additions & 6 deletions test/unit/io/sam_file/format_sam_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,15 @@ TEST_F(sam_format, no_hd_line_in_header)
std::istringstream istream{std::string{"@SQ\tSN:ref\tLN:34\nread1\t41\tref\t1\t61\t*\tref\t10\t300\tACGT\t!##$\n"}};
seqan3::sam_file_input fin{istream, seqan3::format_sam{}, seqan3::fields<seqan3::field::id>{}};

EXPECT_EQ((*fin.begin()).id(), std::string{"read1"});
EXPECT_EQ(fin.front().id(), std::string{"read1"});
}

TEST_F(sam_format, windows_file)
{
std::istringstream istream(std::string("read1\t41\tref\t1\t61\t*\tref\t10\t300\tACGT\t!##$\r\n"));
seqan3::sam_file_input fin{istream, seqan3::format_sam{}, seqan3::fields<seqan3::field::id>{}};

EXPECT_EQ((*fin.begin()).id(), std::string{"read1"});
EXPECT_EQ(fin.front().id(), std::string{"read1"});
}

TEST_F(sam_format, format_error_illegal_character_in_seq)
Expand Down Expand Up @@ -412,8 +412,8 @@ TEST_F(sam_format, issue2195)
using seqan3::operator""_phred42;
std::vector<seqan3::phred42> expected_quality = "*9<9;"_phred42;

EXPECT_RANGE_EQ((*fin.begin()).id(), std::string{"*r1"});
EXPECT_RANGE_EQ((*fin.begin()).base_qualities(), expected_quality);
EXPECT_RANGE_EQ(fin.front().id(), std::string{"*r1"});
EXPECT_RANGE_EQ(fin.front().base_qualities(), expected_quality);
}

{
Expand All @@ -423,7 +423,7 @@ TEST_F(sam_format, issue2195)
using seqan3::operator""_phred42;
std::vector<seqan3::phred42> expected_quality = "*1"_phred42;

EXPECT_RANGE_EQ((*fin.begin()).id(), std::string{""});
EXPECT_RANGE_EQ((*fin.begin()).base_qualities(), expected_quality);
EXPECT_RANGE_EQ(fin.front().id(), std::string{""});
EXPECT_RANGE_EQ(fin.front().base_qualities(), expected_quality);
}
}
24 changes: 12 additions & 12 deletions test/unit/io/sam_file/sam_file_format_test_template.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,18 +252,18 @@ TYPED_TEST_P(sam_file_read, read_in_all_but_empty_data)
typename TestFixture::stream_type istream{this->empty_input};
seqan3::sam_file_input fin{istream, this->ref_ids, this->ref_sequences, TypeParam{}};

EXPECT_TRUE((*fin.begin()).sequence().empty());
EXPECT_TRUE((*fin.begin()).id().empty());
EXPECT_TRUE((*fin.begin()).base_qualities().empty());
EXPECT_TRUE((*fin.begin()).cigar_sequence().empty());
EXPECT_TRUE(!(*fin.begin()).reference_id().has_value());
EXPECT_TRUE(!(*fin.begin()).reference_position().has_value());
EXPECT_EQ((*fin.begin()).flag(), seqan3::sam_flag{0u});
EXPECT_EQ((*fin.begin()).mapping_quality(), 0u);
EXPECT_TRUE(!(*fin.begin()).mate_reference_id().has_value());
EXPECT_TRUE(!(*fin.begin()).mate_position().has_value());
EXPECT_EQ((*fin.begin()).template_length(), int32_t{});
EXPECT_TRUE((*fin.begin()).tags().empty());
EXPECT_TRUE(fin.front().sequence().empty());
EXPECT_TRUE(fin.front().id().empty());
EXPECT_TRUE(fin.front().base_qualities().empty());
EXPECT_TRUE(fin.front().cigar_sequence().empty());
EXPECT_TRUE(!fin.front().reference_id().has_value());
EXPECT_TRUE(!fin.front().reference_position().has_value());
EXPECT_EQ(fin.front().flag(), seqan3::sam_flag{0u});
EXPECT_EQ(fin.front().mapping_quality(), 0u);
EXPECT_TRUE(!fin.front().mate_reference_id().has_value());
EXPECT_TRUE(!fin.front().mate_position().has_value());
EXPECT_EQ(fin.front().template_length(), int32_t{});
EXPECT_TRUE(fin.front().tags().empty());
}

TYPED_TEST_P(sam_file_read, read_in_almost_nothing)
Expand Down
6 changes: 3 additions & 3 deletions test/unit/utility/container/dynamic_bitset_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,9 @@ constexpr bool iterator_test()
seqan3::dynamic_bitset t1{0b1111'0001'0000'1100};
seqan3::dynamic_bitset const t2{0b1010'0001'0000'0011};

bool res = !*t1.begin();
bool res = !t1.front();
res &= !*t1.cbegin();
res &= *t2.begin();
res &= t2.front();
res &= *t2.cbegin();

res &= *(t1.end() - 1);
Expand All @@ -522,7 +522,7 @@ constexpr bool iterator_test()

res &= t1.end() == t1.cend();

*t1.begin() = true;
t1.front() = true;
res &= t1 == seqan3::dynamic_bitset{0b1111'0001'0000'1101};

return res;
Expand Down
6 changes: 3 additions & 3 deletions test/unit/utility/container/small_string_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,18 @@ TEST(small_string, concat)
TEST(small_string, begin)
{
seqan3::small_string s{"hello"};
EXPECT_EQ(*s.begin(), 'h');
EXPECT_EQ(s.front(), 'h');
EXPECT_TRUE((std::is_same_v<decltype(s)::iterator, decltype(s.begin())>));

seqan3::small_string<5> const cs{s};
EXPECT_EQ(*cs.begin(), 'h');
EXPECT_EQ(cs.front(), 'h');
EXPECT_TRUE((std::is_same_v<decltype(cs)::const_iterator, decltype(cs.begin())>));
}

TEST(small_string, cbegin)
{
seqan3::small_string s{"hello"};
EXPECT_EQ(*s.begin(), 'h');
EXPECT_EQ(s.front(), 'h');
EXPECT_TRUE((std::is_same_v<decltype(s)::const_iterator, decltype(s.cbegin())>));
}

Expand Down
6 changes: 3 additions & 3 deletions test/unit/utility/views/pairwise_combine_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ TYPED_TEST(pairwise_combine_test, begin)
auto v = this->create_view();
auto const cv{v};

EXPECT_EQ(*v.begin(), (std::tuple{'a', 'b'}));
EXPECT_EQ(*cv.begin(), (std::tuple{'a', 'b'}));
EXPECT_EQ(v.front(), (std::tuple{'a', 'b'}));
EXPECT_EQ(cv.front(), (std::tuple{'a', 'b'}));
EXPECT_EQ(*std::ranges::cbegin(v), (std::tuple{'a', 'b'}));
}

Expand Down Expand Up @@ -503,7 +503,7 @@ TEST(pairwise_combine_fn_test, output)
std::vector orig{'a', 'b', 'c', 'd'};
auto v = orig | seqan3::views::pairwise_combine;

*v.begin() = std::tuple{'x', 'y'};
v.front() = std::tuple{'x', 'y'};

auto it = v.begin();
EXPECT_EQ(*it, (std::tuple{'x', 'y'}));
Expand Down
6 changes: 3 additions & 3 deletions test/unit/utility/views/repeat_n_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ TEST(view, factory)
std::string str{"foobar"};
auto v = seqan3::views::repeat_n(str, 2);
EXPECT_EQ(v.size(), 2u);
EXPECT_EQ(*v.begin(), str);
EXPECT_EQ(v.front(), str);
EXPECT_EQ(v[0], str);
}

Expand All @@ -76,7 +76,7 @@ TEST(view, factory)
std::string str{"foobar"};
auto view = str | std::views::take(3);
auto v = seqan3::views::repeat_n(view, 5);
EXPECT_RANGE_EQ(*v.begin(), std::string{"foo"});
EXPECT_RANGE_EQ(v.front(), std::string{"foo"});
}

// combinability
Expand All @@ -98,7 +98,7 @@ constexpr char constexpr_view()
auto v = seqan3::views::repeat_n(chr, 10);
v[0] = 'X';

return *v.begin();
return v.front();
}

TEST(general, constexpr_context)
Expand Down
8 changes: 4 additions & 4 deletions test/unit/utility/views/repeat_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ TEST(view, factory)
{
char const chr{'X'};
auto v = seqan3::views::repeat(chr);
EXPECT_EQ(*v.begin(), chr);
EXPECT_EQ(v.front(), chr);
}

// string
{
std::string str{"foobar"};
auto v = seqan3::views::repeat(str);
EXPECT_EQ(*v.begin(), str);
EXPECT_EQ(v.front(), str);
EXPECT_EQ(v[2345], str);
}

Expand All @@ -153,7 +153,7 @@ TEST(view, factory)
std::string const input{"foobar"};
auto view = std::views::take(input, 3);
auto v = seqan3::views::repeat(view);
EXPECT_RANGE_EQ(*v.begin(), view);
EXPECT_RANGE_EQ(v.front(), view);
}

// combinability
Expand Down Expand Up @@ -191,7 +191,7 @@ constexpr char constexpr_view()
auto v = seqan3::views::repeat(chr);
v[1324] = 'X';

return *v.begin();
return v.front();
}

TEST(general, constexpr_context)
Expand Down
6 changes: 3 additions & 3 deletions test/unit/utility/views/zip_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ TEST_F(zip_test, alignment_usage_2)
TEST_F(zip_test, use_as_output_range)
{
auto zip_view = zip_common_range();
*zip_view.begin() = std::pair(23, "FF");
EXPECT_EQ(std::get<0>(*zip_view.begin()), 23);
EXPECT_EQ(std::get<1>(*zip_view.begin()), "FF");
zip_view.front() = std::pair(23, "FF");
EXPECT_EQ(std::get<0>(zip_view.front()), 23);
EXPECT_EQ(std::get<1>(zip_view.front()), "FF");

size_t i{1u};
for (auto && [elem_1, elem_2] : zip_view | std::views::drop(1))
Expand Down
Loading