GCC Code Coverage Report


Directory: include/raberu/impl/
File: include/raberu/impl/algo/drop.hpp
Date: 2026-11-21 10:39:38
Exec Total Coverage
Lines: 4 4 100.0%
Functions: 6 6 100.0%
Branches: 1 1 100.0%

Line Branch Exec Source
1 //======================================================================================================================
2 /*
3 RABERU - Fancy Parameters Library
4 Copyright : RABERU Project Contributors
5 SPDX-License-Identifier: BSL-1.0
6 */
7 //======================================================================================================================
8 #pragma once
9
10 namespace rbr
11 {
12 namespace _
13 {
14 template<typename K, concepts::keyword... Kept> struct filter
15 {
16 using type = _::keys<Kept...>;
17
18 template<typename T> constexpr auto operator+(keys<T> const&) const
19 {
20 using kw_t = typename T::keyword_type;
21 if constexpr (!stdfix::same_as<K, typename kw_t::tag_type>) return filter<K, Kept..., kw_t>{};
22 else return *this;
23 }
24 };
25
26 template<typename K, typename S> struct select_keys;
27
28 template<typename K, concepts::option... Os>
29 struct select_keys<K, rbr::settings<Os...>> : decltype((filter<typename K::tag_type>{} + ... + _::keys<Os>{}))
30 {
31 };
32 }
33
34 //====================================================================================================================
35 //! @ingroup stng
36 //! @related rbr::settings
37 //! @brief Remove an option from a rbr::settings
38 //!
39 //! Build a rbr::settings containing all options from s except for any option bound to the `k`
40 //! rbr::keyword.
41 //!
42 //! @param k Keyword to remove
43 //! @param s Original rbr::settings
44 //! @return An instance of rbr::settings containing all options of `s` except those bound to `k`.
45 //!
46 //! ## Example:
47 //! @include doc/drop.cpp
48 //====================================================================================================================
49 template<concepts::keyword K, concepts::option... O>
50 12 [[nodiscard]] constexpr auto drop([[maybe_unused]] K const& k, settings<O...> const& s)
51 {
52 using selected_keys_t = typename _::select_keys<K, settings<O...>>::type;
53
54 18 return [&]<typename... Ks>(_::keys<Ks...>) {
55 // Rebuild a new settings by going over the keys that we keep
56 6 return rbr::settings{(Ks{} = s[Ks{}])...};
57
1/1
✓ Branch 1 taken 5 times.
22 }(selected_keys_t{});
58 }
59
60 namespace result
61 {
62 template<concepts::keyword K, concepts::option... O> struct drop
63 {
64 using type = decltype(rbr::drop(std::declval<K>(), std::declval<O>()...));
65 };
66
67 template<concepts::keyword K, concepts::option... O> using drop_t = typename drop<K, O...>::type;
68 }
69 }
70