author | Jeff Walden <jwalden@mit.edu> |
Thu, 14 Jun 2012 17:55:11 -0700 | |
changeset 101756 | a112cf3d055d8930f8bdb7f40b8537cc26bab787 |
parent 101755 | 30da794ae32ca71964099e32577ef8f370036ded |
child 101757 | 01844720b147314475896425f6c5ae9e6f363053 |
push id | 1316 |
push user | akeybl@mozilla.com |
push date | Mon, 27 Aug 2012 22:37:00 +0000 |
treeherder | mozilla-beta@db4b09302ee2 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | sparky |
bugs | 616262 |
milestone | 16.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
mfbt/TypeTraits.h | file | annotate | diff | comparison | revisions |
--- a/mfbt/TypeTraits.h +++ b/mfbt/TypeTraits.h @@ -1,54 +1,54 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +/* Template-based metaprogramming and type-testing facilities. */ + #ifndef mozilla_TypeTraits_h_ #define mozilla_TypeTraits_h_ -/* Template-based metaprogramming and type-testing facilities. */ - namespace mozilla { /* * IsBaseOf allows to know whether a given class is derived from another. * * Consider the following class definitions: * * class A {}; * class B : public A {}; * class C {}; * * mozilla::IsBaseOf<A, B>::value is true; * mozilla::IsBaseOf<A, C>::value is false; */ -template <class Base, class Derived> +template<class Base, class Derived> class IsBaseOf { private: - static char Test(Base *); - static int Test(...); + static char test(Base* b); + static int test(...); public: - static const bool value = (sizeof(Test(static_cast<Derived *>(0))) == sizeof(char)); + static const bool value = (sizeof(test(static_cast<Derived*>(0))) == sizeof(char)); }; /* * Conditional selects a class between two, depending on a given boolean value. * * mozilla::Conditional<true, A, B>::Type is A; * mozilla::Conditional<false, A, B>::Type is B; */ -template <bool condition, class A, class B> +template<bool condition, class A, class B> struct Conditional { typedef A Type; }; -template <class A, class B> +template<class A, class B> struct Conditional<false, A, B> { typedef B Type; }; } /* namespace mozilla */ #endif /* mozilla_TypeTraits_h_ */