2013-04-16 20:47:10 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
2012-05-21 11:12:37 +00:00
|
|
|
* 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/. */
|
2009-07-01 00:19:42 +00:00
|
|
|
|
2013-06-20 00:59:09 +00:00
|
|
|
#ifndef js_Vector_h
|
|
|
|
#define js_Vector_h
|
2009-07-01 00:19:42 +00:00
|
|
|
|
2013-07-09 23:33:29 +00:00
|
|
|
#include "mozilla/Vector.h"
|
2009-08-08 03:09:11 +00:00
|
|
|
|
2010-08-02 14:44:24 +00:00
|
|
|
/* Silence dire "bugs in previous versions of MSVC have been fixed" warnings */
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning(push)
|
|
|
|
#pragma warning(disable:4345)
|
|
|
|
#endif
|
|
|
|
|
2009-09-02 01:46:19 +00:00
|
|
|
namespace js {
|
2009-07-01 00:19:42 +00:00
|
|
|
|
2012-01-02 22:34:25 +00:00
|
|
|
class TempAllocPolicy;
|
|
|
|
|
2013-07-09 23:33:29 +00:00
|
|
|
// If we had C++11 template aliases, we could just use this:
|
|
|
|
//
|
|
|
|
// template <typename T,
|
|
|
|
// size_t MinInlineCapacity = 0,
|
|
|
|
// class AllocPolicy = TempAllocPolicy>
|
|
|
|
// using Vector = mozilla::Vector<T, MinInlineCapacity, AllocPolicy>;
|
|
|
|
//
|
|
|
|
// ...and get rid of all the CRTP madness in mozilla::Vector(Base). But we
|
|
|
|
// can't because compiler support's not up to snuff. (Template aliases are in
|
|
|
|
// gcc 4.7 and clang 3.0 and are expected to be in MSVC 2013.) Instead, have a
|
|
|
|
// completely separate class inheriting from mozilla::Vector, and throw CRTP at
|
|
|
|
// the problem til things work.
|
|
|
|
//
|
|
|
|
// This workaround presents a couple issues. First, because js::Vector is a
|
|
|
|
// distinct type from mozilla::Vector, overload resolution, method calls, etc.
|
|
|
|
// are affected. *Hopefully* this won't be too bad in practice. (A bunch of
|
|
|
|
// places had to be fixed when mozilla::Vector was introduced, but it wasn't a
|
|
|
|
// crazy number.) Second, mozilla::Vector's interface has to be made subclass-
|
|
|
|
// ready via CRTP -- or rather, via mozilla::VectorBase, which basically no one
|
|
|
|
// should use. :-) Third, we have to redefine the constructors and the non-
|
|
|
|
// inherited operators. Blech. Happily there aren't too many of these, so it
|
|
|
|
// isn't the end of the world.
|
|
|
|
|
|
|
|
template <typename T,
|
2012-01-02 22:34:25 +00:00
|
|
|
size_t MinInlineCapacity = 0,
|
|
|
|
class AllocPolicy = TempAllocPolicy>
|
2013-07-09 23:33:29 +00:00
|
|
|
class Vector
|
|
|
|
: public mozilla::VectorBase<T,
|
|
|
|
MinInlineCapacity,
|
|
|
|
AllocPolicy,
|
|
|
|
Vector<T, MinInlineCapacity, AllocPolicy> >
|
2009-07-01 00:19:42 +00:00
|
|
|
{
|
2013-07-09 23:33:29 +00:00
|
|
|
typedef typename mozilla::VectorBase<T, MinInlineCapacity, AllocPolicy, Vector> Base;
|
2011-03-08 20:44:42 +00:00
|
|
|
|
2009-07-01 00:19:42 +00:00
|
|
|
public:
|
2014-05-26 01:46:24 +00:00
|
|
|
explicit Vector(AllocPolicy alloc = AllocPolicy()) : Base(alloc) {}
|
2013-11-19 17:05:36 +00:00
|
|
|
Vector(Vector &&vec) : Base(mozilla::Move(vec)) {}
|
|
|
|
Vector &operator=(Vector &&vec) {
|
|
|
|
return Base::operator=(mozilla::Move(vec));
|
2011-02-19 02:32:29 +00:00
|
|
|
}
|
2009-08-08 03:09:11 +00:00
|
|
|
};
|
2009-07-01 00:19:42 +00:00
|
|
|
|
2013-07-09 23:33:29 +00:00
|
|
|
} // namespace js
|
2010-08-02 14:44:24 +00:00
|
|
|
|
2013-06-20 00:59:09 +00:00
|
|
|
#endif /* js_Vector_h */
|