mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-18 01:15:39 +00:00
Allow ResultOrError to downcast from backend to frontend types
More concretely this makes Result<T*, E*> able to be move-constructed from Result<ChildClassOfT*, E*> for free. BUG=dawn:19 Change-Id: Iea2b8997079ac3bfcf270d6b73a79cf5cac2c06f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11860 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
5f53d5302f
commit
bd481fc199
@@ -139,6 +139,31 @@ TEST(ResultBothPointer, ReturningSuccess) {
|
||||
TestSuccess(&result, &dummySuccess);
|
||||
}
|
||||
|
||||
// Tests converting from a Result<TChild*, E*>
|
||||
TEST(ResultBothPointer, ConversionFromChildClass) {
|
||||
struct T {
|
||||
int a;
|
||||
};
|
||||
struct TChild : T {};
|
||||
|
||||
TChild child;
|
||||
T* childAsT = &child;
|
||||
{
|
||||
Result<T*, int*> result(&child);
|
||||
TestSuccess(&result, childAsT);
|
||||
}
|
||||
{
|
||||
Result<TChild*, int*> resultChild(&child);
|
||||
Result<T*, int*> result(std::move(resultChild));
|
||||
TestSuccess(&result, childAsT);
|
||||
}
|
||||
{
|
||||
Result<TChild*, int*> resultChild(&child);
|
||||
Result<T*, int*> result = std::move(resultChild);
|
||||
TestSuccess(&result, childAsT);
|
||||
}
|
||||
}
|
||||
|
||||
// Result<const T*, E*>
|
||||
|
||||
// Test constructing an error Result<const T*, E*>
|
||||
|
||||
Reference in New Issue
Block a user