boostorg / boostorg/mp11

boost::mp11::mp_transform is not SFINAE friendly on transform error

Open
#101 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
291
Forks
97
PR merge metrics
No merged PRs in 30d

Description

Example could be found below or on [godbolt](https://godbolt.org/z/rE91a8c1a). boost::mp11::mp_transform is not SFINAE friendly on transform error. It is SFINAE friendly on size mismatch though. It would be very helpful in constraints if it is SFINAE friendly.

```
template typename F, typename... List>
concept has_boost_mp_transform = requires { typename boost::mp11::mp_transform; };

static_assert(!has_boost_mp_transform, std::tuple>); // invalid transform. Does not compile.
static_assert(!has_boost_mp_transform, boost::mp11::mp_list>); // invalid transform result. Does not compile.
static_assert(!has_boost_mp_transform, boost::mp11::mp_list>); // size mismatch. Compiles.
```

An example implementation for c++20 could be found below or on [godbolt](https://godbolt.org/z/j4svze7M3).

```
namespace no_adl {
template typename F, typename List0, typename... List>
struct mp_transform_impl {};

template typename F, template typename TList0, typename... List>
struct mp_transform_impl, List...> {
using type = TList0<>;
};

template typename F, template typename TList0, typename T0, typename... T, typename... List> requires
requires { typename F...>; } &&
requires { typename mp_transform_impl, boost::mp11::mp_pop_front...>::type; }
struct mp_transform_impl, List...> {
using type = boost::mp11::mp_append<
TList0...>>,
typename mp_transform_impl, boost::mp11::mp_pop_front...>::type
>;
};

template typename F, typename... List>
requires boost::mp11::mp_same...>::value && (0 {};
}

template typename F, typename... List>
using mp_transform = typename no_adl::mp_transform::type;
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.