Date: Tue, 15 Sep 2020 14:29:34 +0200
wt., 15 wrz 2020 o 14:16 Victor Khomenko
<victor.khomenko_at_[hidden]> napisaĆ(a):
>
> > One important thing, if this tag have variant inside it, then it should be
> > tempted by it like:
> > ```
> > template<typename Var, size_t Index>
> > struct variant_tag
>
> True - I expect we'll need to include a prototype implementation (e.g. on the basis of existing std::variant) into the proposal, so should catch bugs like this.
>
>
Yup, but for `std::visit`, I do not think we could mix both versions,
it could have corner cases that make hard to solve, like:
```
[](auto f){}, //this will get `T&` or tag?
[]<int I>(variant_tag<V, I> t) {}, //this will be selected over `auto`
or `int&`?
```
Probaby if we want use same `std::visit` then we should define exactly
how overload are chosen, something like this:
```
if constexpr (callable_v<F, T&>)
{
return f(get<I>(v));
}
else if constexpr (callable_v<F, variant_tag<V, I>>)
{
return f(variant_tag<V, I>{ v });
}
```
<victor.khomenko_at_[hidden]> napisaĆ(a):
>
> > One important thing, if this tag have variant inside it, then it should be
> > tempted by it like:
> > ```
> > template<typename Var, size_t Index>
> > struct variant_tag
>
> True - I expect we'll need to include a prototype implementation (e.g. on the basis of existing std::variant) into the proposal, so should catch bugs like this.
>
>
Yup, but for `std::visit`, I do not think we could mix both versions,
it could have corner cases that make hard to solve, like:
```
[](auto f){}, //this will get `T&` or tag?
[]<int I>(variant_tag<V, I> t) {}, //this will be selected over `auto`
or `int&`?
```
Probaby if we want use same `std::visit` then we should define exactly
how overload are chosen, something like this:
```
if constexpr (callable_v<F, T&>)
{
return f(get<I>(v));
}
else if constexpr (callable_v<F, variant_tag<V, I>>)
{
return f(variant_tag<V, I>{ v });
}
```
Received on 2020-09-15 07:29:47