-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TEST] add tests and examples and deprecate old views::to
- Loading branch information
Showing
6 changed files
with
327 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include <deque> | ||
#include <forward_list> | ||
#include <list> | ||
#include <vector> | ||
|
||
#include <seqan3/utility/range/to.hpp> | ||
|
||
int main() | ||
{ | ||
auto lst = std::views::iota(1, 10); // some range over the numbers 1-10 | ||
|
||
// convert range to vector using pipe syntax | ||
auto vec0 = lst | seqan3::ranges::to<std::vector<int>>(); | ||
static_assert(std::same_as<decltype(vec0), std::vector<int>>); | ||
|
||
// convert range to vector but auto deducing the element type | ||
auto vec1 = lst | seqan3::ranges::to<std::vector>(); | ||
static_assert(std::same_as<decltype(vec1), std::vector<int>>); | ||
|
||
// convert range to vector using function call syntax | ||
auto vec2 = seqan3::ranges::to<std::vector<int>>(lst); | ||
static_assert(std::same_as<decltype(vec2), std::vector<int>>); | ||
|
||
// using function call syntax and auto deducing element type | ||
auto vec3 = seqan3::ranges::to<std::vector>(lst); | ||
static_assert(std::same_as<decltype(vec3), std::vector<int>>); | ||
|
||
// convert nested ranges into nested containers | ||
auto nested_lst = std::list<std::forward_list<int>>{{1, 2, 3}, {4, 5, 6, 7}}; | ||
auto vec4 = nested_lst | seqan3::ranges::to<std::vector<std::vector<int>>>(); | ||
static_assert(std::same_as<decltype(vec), std::vector<std::vector<int>>>); | ||
|
||
// different supported container types | ||
auto vec5 = lst | seqan3::ranges::to<std::list>(); | ||
static_assert(std::same_as<decltype(vec5), std::list<int>>); | ||
|
||
auto vec5 = lst | seqan3::ranges::to<std::deque>(); | ||
static_assert(std::same_as<decltype(vec5), std::deque<int>>); | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
add_subdirectories () | ||
|
||
seqan3_test (to_test.cpp) |
Oops, something went wrong.