BioC++ core-0.7.0
The Modern C++ libraries for Bioinformatics.
 
Loading...
Searching...
No Matches
validate_char_for.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2022 deCODE Genetics
3// Copyright (c) 2006-2022, Knut Reinert & Freie Universität Berlin
4// Copyright (c) 2016-2022, Knut Reinert & MPI für molekulare Genetik
5// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
6// shipped with this file and also available at: https://github.com/biocpp/biocpp-core/blob/main/LICENSE.md
7// -----------------------------------------------------------------------------------------------------
8
14#pragma once
15
16#include <ranges>
17
21
22namespace bio::ranges::views
23{
76template <alphabet::alphabet alphabet_type>
77inline auto const validate_char_for = deep{std::views::transform(
78 []<typename char_t>(char_t && in) -> char_t
79 {
80 static_assert(std::common_reference_with<char_t, alphabet::char_t<alphabet_type>>,
81 "The innermost value type must have a common reference to underlying char type of alphabet_type.");
82
83 if (!alphabet::char_is_valid_for<alphabet_type>(in))
84 {
85 throw alphabet::invalid_char_assignment{"alphabet_type", in};
86 }
87 return std::forward<char_t>(in);
88 })};
89
91
92} // namespace bio::ranges::views
Core alphabet concept and free function/type trait wrappers.
Provides various type traits on generic types.
A wrapper type around an existing view adaptor that enables "deep view" behaviour for that view.
Definition: deep.hpp:104
Provides bio::views::deep.
auto const validate_char_for
An identity view that throws if an encountered character is not valid for the given alphabet.
Definition: validate_char_for.hpp:77
The BioC++ namespace for views.
An exception typically thrown by bio::alphabet::assign_char_strict.
Definition: exception.hpp:27