diff options
author | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-08 14:22:56 +0000 |
---|---|---|
committer | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-08 14:22:56 +0000 |
commit | 7340a68ff7f45460c0a71f1397737079cbf4d59d (patch) | |
tree | 9e7399c1173e68837553b6236929f18c7107b88c /base | |
parent | 985b4bebe40fcf7af248c4580fa8cf0d503f87a7 (diff) | |
download | chromium_src-7340a68ff7f45460c0a71f1397737079cbf4d59d.zip chromium_src-7340a68ff7f45460c0a71f1397737079cbf4d59d.tar.gz chromium_src-7340a68ff7f45460c0a71f1397737079cbf4d59d.tar.bz2 |
Remove some unused stuff from basictypes.h.
My original goal was just to remove down_cast, since it uses RTTI, and I am
going to update the build with -fno-rtti. The other stuff I just noticed is
unrelated and unused in our code, so we might as well remove it, since it
hasn't proven to be useful.
Review URL: http://codereview.chromium.org/63121
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13349 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/basictypes.h | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/base/basictypes.h b/base/basictypes.h index 46b8364..e596ab8 100644 --- a/base/basictypes.h +++ b/base/basictypes.h @@ -5,7 +5,6 @@ #ifndef BASE_BASICTYPES_H_ #define BASE_BASICTYPES_H_ -#include <assert.h> // for use with down_cast<> #include <limits.h> // So we can set the bounds of our types #include <stddef.h> // For size_t #include <string.h> // for memcpy @@ -186,39 +185,6 @@ inline To implicit_cast(From const &f) { return f; } - -// When you upcast (that is, cast a pointer from type Foo to type -// SuperclassOfFoo), it's fine to use implicit_cast<>, since upcasts -// always succeed. When you downcast (that is, cast a pointer from -// type Foo to type SubclassOfFoo), static_cast<> isn't safe, because -// how do you know the pointer is really of type SubclassOfFoo? It -// could be a bare Foo, or of type DifferentSubclassOfFoo. Thus, -// when you downcast, you should use this macro. In debug mode, we -// use dynamic_cast<> to double-check the downcast is legal (we die -// if it's not). In normal mode, we do the efficient static_cast<> -// instead. Thus, it's important to test in debug mode to make sure -// the cast is legal! -// This is the only place in the code we should use dynamic_cast<>. -// In particular, you SHOULDN'T be using dynamic_cast<> in order to -// do RTTI (eg code like this: -// if (dynamic_cast<Subclass1>(foo)) HandleASubclass1Object(foo); -// if (dynamic_cast<Subclass2>(foo)) HandleASubclass2Object(foo); -// You should design the code some other way not to need this. - -template<typename To, typename From> // use like this: down_cast<T*>(foo); -inline To down_cast(From* f) { // so we only accept pointers - // Ensures that To is a sub-type of From *. This test is here only - // for compile-time type checking, and has no overhead in an - // optimized build at run-time, as it will be optimized away - // completely. - if (false) { - implicit_cast<From*, To>(0); - } - - assert(f == NULL || dynamic_cast<To>(f) != NULL); // RTTI: debug mode only! - return static_cast<To>(f); -} - // The COMPILE_ASSERT macro can be used to verify that a compile time // expression is true. For example, you could use it to verify the // size of a static array: @@ -296,20 +262,6 @@ enum Ownership { TAKE_OWNERSHIP }; -// Use these as the mlock_bytes parameter to MLock and MLockGeneral -enum { MLOCK_ALL = -1, MLOCK_NONE = 0 }; - -// Helper routine to avoid buggy code like the following: -// if (pos + N < end) ... -// If pos is large enough, "pos + N" may overflow. For example, -// pos==0xfffff000 and N==1MB. -// -// PointerRangeSize(a,b) returns the size of the range [a,b-1] -inline size_t PointerRangeSize(const char* start, const char* end) { - assert(start <= end); - return end - start; -} - // bit_cast<Dest,Source> is a template function that implements the // equivalent of "*reinterpret_cast<Dest*>(&source)". We need this in // very low-level functions like the protobuf library and fast math |