@@ -133,62 +133,13 @@ char (&ArraySizeHelper(const T (&array)[N]))[N];
133133#define AS_STRING (x ) AS_STRING_INTERNAL(x)
134134#define AS_STRING_INTERNAL (x ) #x
135135
136-
137- // One of the type traits, is_pod, makes it possible to query whether
138- // a type is a POD type. It is impossible for type_traits.h to get
139- // this right without compiler support, so it fails conservatively. It
140- // knows that fundamental types and pointers are PODs, but it can't
141- // tell whether user classes are PODs. The DECLARE_POD macro is used
142- // to inform the type traits library that a user class is a POD.
143- //
144- // Implementation note: the typedef at the end is just to make it legal
145- // to put a semicolon after DECLARE_POD(foo).
146- //
147- // The only reason this matters is that a few parts of the google3
148- // code base either require their template arguments to be PODs
149- // (e.g. compact_vector) or are able to use a more efficient code path
150- // when their template arguments are PODs (e.g. sparse_hash_map). You
151- // should use DECLARE_POD if you have written a class that you intend
152- // to use with one of those components, and if you know that your
153- // class satisfies all of the conditions to be a POD type.
154- //
155- // So what's a POD? The C++ standard (clause 9 paragraph 4) gives a
156- // full definition, but a good rule of thumb is that a struct is a POD
157- // ("plain old data") if it doesn't use any of the features that make
158- // C++ different from C. A POD struct can't have constructors,
159- // destructors, assignment operators, base classes, private or
160- // protected members, or virtual functions, and all of its member
161- // variables must themselves be PODs.
162-
163- #define DECLARE_POD (TypeName ) \
164- namespace std { \
165- template <> struct is_pod <TypeName> : true_type { }; \
166- } \
167- typedef int Dummy_Type_For_DECLARE_POD \
168-
169- // We once needed a different technique to assert that a nested class
170- // is a POD. This is no longer necessary, and DECLARE_NESTED_POD is
171- // just a synonym for DECLARE_POD. We continue to provide
172- // DECLARE_NESTED_POD only so we don't have to change client
173- // code. Regardless of whether you use DECLARE_POD or
174- // DECLARE_NESTED_POD: use it after the outer class. Using it within a
175- // class definition will give a compiler error.
136+ // These macros are a mess of undefined behavior that specialize std::is_pod to
137+ // pretend that non-POD types are POD, which is both invalid and would do very
138+ // broken things. Fortunately s2 internally does not actually rely on this and
139+ // we can make them no-ops.
140+ #define DECLARE_POD (TypeName )
176141#define DECLARE_NESTED_POD (TypeName ) DECLARE_POD(TypeName)
177-
178- // Declare that TemplateName<T> is a POD whenever T is
179- #define PROPAGATE_POD_FROM_TEMPLATE_ARGUMENT (TemplateName ) \
180- namespace std { \
181- template <typename T> struct is_pod <TemplateName<T> > : std::is_trivial<T> { }; \
182- } \
183- typedef int Dummy_Type_For_PROPAGATE_POD_FROM_TEMPLATE_ARGUMENT
184-
185- // Macro that does nothing if TypeName is a POD, and gives a compiler
186- // error if TypeName is a non-POD. You should put a descriptive
187- // comment right next to the macro call so that people can tell what
188- // the compiler error is about.
189- //
190- // Implementation note: this works by taking the size of a type that's
191- // complete when TypeName is a POD and incomplete otherwise.
142+ #define PROPAGATE_POD_FROM_TEMPLATE_ARGUMENT (TemplateName )
192143
193144template <bool IsPod> struct ERROR_TYPE_MUST_BE_POD ;
194145template <> struct ERROR_TYPE_MUST_BE_POD <true > { };
0 commit comments