Loading...
Searching...
No Matches
core/range/type_traits.hpp
Go to the documentation of this file.
// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: BSD-3-Clause
#pragma once
#include <iterator>
#include <ranges>
#include <type_traits>
#include <seqan3/core/detail/iterator_traits.hpp>
#include <seqan3/core/platform.hpp>
#include <seqan3/utility/type_traits/basic.hpp>
// TODO(h-2): add innermost_reference instead of or addition to range_innermost_value?
//NOTE(h-2): for the range overloads we explicitly forbid that the type is iteratoer
// because some types are actually both (e.g. std::directory_iterator)
namespace seqan3::detail
{
template <typename t>
concept has_range_value_type = requires { typename std::ranges::range_value_t<std::remove_cvref_t<t>>; };
template <bool const_range, typename range_t>
using maybe_const_range_t = std::conditional_t<const_range, range_t const, range_t>;
template <bool const_range, typename range_t>
using maybe_const_iterator_t = std::ranges::iterator_t<maybe_const_range_t<const_range, range_t>>;
template <bool const_v, typename range_t>
using maybe_const_sentinel_t = std::ranges::sentinel_t<maybe_const_range_t<const_v, range_t>>;
template <typename unary_predicate_fn_t, typename urng_t>
concept indirect_unary_predicate_on_range =
std::ranges::range<urng_t> && std::indirect_unary_predicate<unary_predicate_fn_t, std::ranges::iterator_t<urng_t>>;
} // namespace seqan3::detail
namespace seqan3
{
// ----------------------------------------------------------------------------
// range_innermost_value
// ----------------------------------------------------------------------------
template <typename t>
requires detail::has_range_value_type<t>
struct range_innermost_value
{
using type = std::ranges::range_value_t<std::remove_cvref_t<t>>;
};
template <typename t>
requires detail::has_range_value_type<t>
&& detail::has_range_value_type<std::ranges::range_value_t<std::remove_cvref_t<t>>>
struct range_innermost_value<t>
{
using type = typename range_innermost_value<std::ranges::range_value_t<std::remove_cvref_t<t>>>::type;
};
template <typename t>
using range_innermost_value_t = typename range_innermost_value<t>::type;
// ----------------------------------------------------------------------------
// range_dimension_v
// ----------------------------------------------------------------------------
template <typename t>
requires detail::has_range_value_type<t>
constexpr size_t range_dimension_v = 1;
template <typename t>
requires detail::has_range_value_type<t>
&& detail::has_range_value_type<std::ranges::range_value_t<std::remove_cvref_t<t>>>
constexpr size_t range_dimension_v<t> = range_dimension_v<std::ranges::range_value_t<std::remove_cvref_t<t>>> + 1;
} // namespace seqan3
basic.hpp
Provides various type traits on generic types.
seqan3::range_innermost_value_t
typename range_innermost_value< t >::type range_innermost_value_t
Shortcut for seqan3::range_innermost_value (transformation_trait shortcut).
Definition core/range/type_traits.hpp:95
seqan3::range_dimension_v
constexpr size_t range_dimension_v
Returns the number of times you can call seqan3::value_type_t recursively on t (type trait).
Definition core/range/type_traits.hpp:112
iterator_traits.hpp
Provides various transformation traits for use on iterators.
iterator
seqan3
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
platform.hpp
Provides platform and dependency checks.
seqan3::range_innermost_value
Recursively determines the value_type on containers and/or iterators.
Definition core/range/type_traits.hpp:76
seqan3::range_innermost_value::type
std::ranges::range_value_t< std::remove_cvref_t< t > > type
The return type (recursion not shown).
Definition core/range/type_traits.hpp:78
type_traits
Hide me