| Index: mojo/public/cpp/bindings/lib/template_util.h
|
| diff --git a/mojo/public/cpp/bindings/lib/template_util.h b/mojo/public/cpp/bindings/lib/template_util.h
|
| index ceaf8e08e2bcad2973cc51c9d186964135f534ce..68390c124d395312de1c24eb77c4a3e1ac15189e 100644
|
| --- a/mojo/public/cpp/bindings/lib/template_util.h
|
| +++ b/mojo/public/cpp/bindings/lib/template_util.h
|
| @@ -70,18 +70,24 @@ template <typename A>
|
| struct IsSame<A, A> {
|
| static bool const value = true;
|
| };
|
| +
|
| +template <typename T>
|
| +struct EnsureTypeIsComplete {
|
| + // sizeof() cannot be applied to incomplete types, this line will fail
|
| + // compilation if T is forward declaration.
|
| + using CheckSize = char (*)[sizeof(T)];
|
| +};
|
| +
|
| template <typename Base, typename Derived>
|
| struct IsBaseOf {
|
| private:
|
| - // This class doesn't work correctly with forward declarations.
|
| - // Because sizeof cannot be applied to incomplete types, this line prevents us
|
| - // from passing in forward declarations.
|
| - typedef char (*EnsureTypesAreComplete)[sizeof(Base) + sizeof(Derived)];
|
| -
|
| static Derived* CreateDerived();
|
| static char(&Check(Base*))[1];
|
| static char(&Check(...))[2];
|
|
|
| + EnsureTypeIsComplete<Base> check_base_;
|
| + EnsureTypeIsComplete<Derived> check_derived_;
|
| +
|
| public:
|
| static bool const value = sizeof Check(CreateDerived()) == 1 &&
|
| !IsSame<Base const, void const>::value;
|
|
|