| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
We have a kind of test in Chrome called a nocompile test that proves that certain bad forms won't pass the compiler. I was trying to write one for the mismatched enum case here, but we don't have the infrastructure copied over from Chrome to do so. So what I ask is that you try something locally like
enum A { kA1, kA2 };
enum B ( kB1, kB2 };
Mask<A>(kA1, kB2);
and double-check that compilation breaks because of no matching template. Once you've done that, you're good to go.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
We have a kind of test in Chrome called a nocompile test that proves that certain bad forms won't pass the compiler. I was trying to write one for the mismatched enum case here, but we don't have the infrastructure copied over from Chrome to do so. So what I ask is that you try something locally like
enum A { kA1, kA2 };
enum B ( kB1, kB2 };Mask<A>(kA1, kB2);
and double-check that compilation breaks because of no matching template. Once you've done that, you're good to go.
Yep, tried that out:
```
[0/230] 6.44s F CXX obj/fpdfsdk/pwl/pwl/cpwl_combo_box.o
...
stderr:
In file included from ../../fpdfsdk/pwl/cpwl_combo_box.cpp:7:
In file included from ../../fpdfsdk/pwl/cpwl_combo_box.h:13:
In file included from ../../fpdfsdk/pwl/cpwl_wnd.h:14:
../../core/fxcrt/mask.h:85:12: error: expected ')'
85 | Mask<A>(kA1, kB2);
| ^
../../core/fxcrt/mask.h:85:8: note: to match this '('
85 | Mask<A>(kA1, kB2);
| ^
../../core/fxcrt/mask.h:85:9: error: redefinition of 'kA1' as different kind of symbol
85 | Mask<A>(kA1, kB2);
| ^
../../core/fxcrt/mask.h:82:10: note: previous definition is here
82 | enum A { kA1, kA2 };
| ^
2 errors generated.
```
Seems to work.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Unfortunately, that's not quite the error I'd expect - can you give me the source?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
```
template <std::same_as<E>... Args>
constexpr Mask(E first, Args... rest)
: val_((static_cast<UnderlyingType>(first) | ... |
static_cast<UnderlyingType>(rest))) {}
```
This is the code I am currently using.
The test itself is later in the same file. Which I have in there for testing, although i also have a similar test outside in another file that imports it, to test if that is causing anything.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Yeah, that's the code. But I didn't see the test itself uploaded (not that it would compile, but you're getting a basic syntax error as opposed to a template deduction failure, so I'd need to look at the test.. Am I missing something?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Tried debugging it a bit, turns out this works:
```
enum A { kA1, kA2 };
enum B { kB1, kB2 };
auto pleaseDontCompile = Mask<A>(kA1, kB2, kA2);
```
I just left this here for local testing, so excuse the... variable naming.
It now returns:
```
../../core/fxcrt/mask.h:85:26: error: no matching constructor for initialization of 'Mask<A>'
85 | auto pleaseDontCompile = Mask<A>(kA1, kB2, kA2);
| ^ ~~~~~~~~~~~~~
../../core/fxcrt/mask.h:30:13: note: candidate template ignored: constraints not satisfied [with Args = <B, A>]
30 | constexpr Mask(E first, Args... rest)
| ^
../../core/fxcrt/mask.h:29:13: note: because 'std::same_as<B, A>' evaluated to false
29 | template <std::same_as<E>... Args>
| ^
gen/third_party/libc++/src/include/__concepts/same_as.h:29:19: note: because '__same_as_impl<B, A>' evaluated to false
29 | concept same_as = __same_as_impl<_Tp, _Up> && __same_as_impl<_Up, _Tp>;
| ^
gen/third_party/libc++/src/include/__concepts/same_as.h:26:26: note: because '_IsSame<B, A>::value' evaluated to false
26 | concept __same_as_impl = _IsSame<_Tp, _Up>::value;
| ^
../../core/fxcrt/mask.h:24:13: note: candidate constructor not viable: requires single argument 'that', but 3 arguments were provided
24 | constexpr Mask(const Mask& that) = default;
| ^ ~~~~~~~~~~~~~~~~
../../core/fxcrt/mask.h:27:13: note: candidate constructor not viable: requires single argument 'val', but 3 arguments were provided
27 | constexpr Mask(E val) : val_(static_cast<UnderlyingType>(val)) {}
| ^ ~~~~~
../../core/fxcrt/mask.h:73:22: note: candidate constructor not viable: requires single argument 'val', but 3 arguments were provided
73 | explicit constexpr Mask(UnderlyingType val) : val_(val) {}
| ^ ~~~~~~~~~~~~~~~~~~
../../core/fxcrt/mask.h:23:13: note: candidate constructor not viable: requires 0 arguments, but 3 were provided
23 | constexpr Mask() = default;
| ^
1 error generated.
```
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Yes, that's the error we need to see. But for the sake of completeness, what happened in the two-argument case?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Yes: works for 2 as well.
```
stderr:
In file included from ../../xfa/fxfa/parser/cxfa_overflow.cpp:7:
In file included from ../../xfa/fxfa/parser/cxfa_overflow.h:10:
In file included from ../../xfa/fxfa/parser/cxfa_node.h:18:
../../core/fxcrt/mask.h:86:26: error: no matching constructor for initialization of 'Mask<A>'
86 | auto pleaseDontCompile = Mask<A>(kA1, kB2);
| ^ ~~~~~~~~
../../core/fxcrt/mask.h:30:13: note: candidate template ignored: constraints not satisfied [with Args = <B>]
30 | constexpr Mask(E first, Args... rest)
| ^
../../core/fxcrt/mask.h:29:13: note: because 'std::same_as<B, A>' evaluated to false
29 | template <std::same_as<E>... Args>
| ^
gen/third_party/libc++/src/include/__concepts/same_as.h:29:19: note: because '__same_as_impl<B, A>' evaluated to false
29 | concept same_as = __same_as_impl<_Tp, _Up> && __same_as_impl<_Up, _Tp>;
| ^
gen/third_party/libc++/src/include/__concepts/same_as.h:26:26: note: because '_IsSame<B, A>::value' evaluated to false
26 | concept __same_as_impl = _IsSame<_Tp, _Up>::value;
| ^
../../core/fxcrt/mask.h:24:13: note: candidate constructor not viable: requires single argument 'that', but 2 arguments were provided
24 | constexpr Mask(const Mask& that) = default;
| ^ ~~~~~~~~~~~~~~~~
../../core/fxcrt/mask.h:27:13: note: candidate constructor not viable: requires single argument 'val', but 2 arguments were provided
27 | constexpr Mask(E val) : val_(static_cast<UnderlyingType>(val)) {}
| ^ ~~~~~
../../core/fxcrt/mask.h:73:22: note: candidate constructor not viable: requires single argument 'val', but 2 arguments were provided
73 | explicit constexpr Mask(UnderlyingType val) : val_(val) {}
| ^ ~~~~~~~~~~~~~~~~~~
../../core/fxcrt/mask.h:23:13: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
23 | constexpr Mask() = default;
| ^
1 error generated.
```
with code:
```
enum A { kA1, kA2 };
enum B { kB1, kB2 };
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |