michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef js_Vector_h michael@0: #define js_Vector_h michael@0: michael@0: #include "mozilla/Vector.h" michael@0: michael@0: /* Silence dire "bugs in previous versions of MSVC have been fixed" warnings */ michael@0: #ifdef _MSC_VER michael@0: #pragma warning(push) michael@0: #pragma warning(disable:4345) michael@0: #endif michael@0: michael@0: namespace js { michael@0: michael@0: class TempAllocPolicy; michael@0: michael@0: // If we had C++11 template aliases, we could just use this: michael@0: // michael@0: // template michael@0: // using Vector = mozilla::Vector; michael@0: // michael@0: // ...and get rid of all the CRTP madness in mozilla::Vector(Base). But we michael@0: // can't because compiler support's not up to snuff. (Template aliases are in michael@0: // gcc 4.7 and clang 3.0 and are expected to be in MSVC 2013.) Instead, have a michael@0: // completely separate class inheriting from mozilla::Vector, and throw CRTP at michael@0: // the problem til things work. michael@0: // michael@0: // This workaround presents a couple issues. First, because js::Vector is a michael@0: // distinct type from mozilla::Vector, overload resolution, method calls, etc. michael@0: // are affected. *Hopefully* this won't be too bad in practice. (A bunch of michael@0: // places had to be fixed when mozilla::Vector was introduced, but it wasn't a michael@0: // crazy number.) Second, mozilla::Vector's interface has to be made subclass- michael@0: // ready via CRTP -- or rather, via mozilla::VectorBase, which basically no one michael@0: // should use. :-) Third, we have to redefine the constructors and the non- michael@0: // inherited operators. Blech. Happily there aren't too many of these, so it michael@0: // isn't the end of the world. michael@0: michael@0: template michael@0: class Vector michael@0: : public mozilla::VectorBase > michael@0: { michael@0: typedef typename mozilla::VectorBase Base; michael@0: michael@0: public: michael@0: Vector(AllocPolicy alloc = AllocPolicy()) : Base(alloc) {} michael@0: Vector(Vector &&vec) : Base(mozilla::Move(vec)) {} michael@0: Vector &operator=(Vector &&vec) { michael@0: return Base::operator=(mozilla::Move(vec)); michael@0: } michael@0: }; michael@0: michael@0: } // namespace js michael@0: michael@0: #endif /* js_Vector_h */