GuillaumeDua / CppShelf

Collection of powerfuls - C++ Single-Header Libraries Files
https://guillaumedua.github.io/CppShelf/
MIT License
9 stars 1 forks source link

[mp] replace #163

Open GuillaumeDua opened 9 months ago

GuillaumeDua commented 9 months ago
// replace
template <typename, typename, typename>
struct replace;
template <template <typename ...> typename pack, typename ... Ts, typename old_t, typename new_t>
struct replace<pack<Ts...>, old_t, new_t> : std::type_identity<
    pack<
        std::conditional_t<
            std::is_same_v<Ts, old_t>,
            new_t,
            Ts
        >...
    >
>{};
template <typename pack, typename old_t, typename new_t>
using replace_t = replace<pack, old_t, new_t>::type;