diff options
author | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-11 19:49:34 -0800 |
---|---|---|
committer | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-11 19:49:34 -0800 |
commit | 0333e02340fe245ac17305d9d721328544234ac1 (patch) | |
tree | d66962ac58ce6c0ac66e8cf385ae77fac9c1bd5c /crawl-ref/source/fixvec.h | |
parent | 1b6b184131408cd70789fa8840be7ae59fcdad4b (diff) | |
download | crawl-ref-0333e02340fe245ac17305d9d721328544234ac1.tar.gz crawl-ref-0333e02340fe245ac17305d9d721328544234ac1.zip |
FixedVector varargs init method used by tilepick
Revert removal of varargs init method for FixedVector, since tilepick.cc
uses it.
Diffstat (limited to 'crawl-ref/source/fixvec.h')
-rw-r--r-- | crawl-ref/source/fixvec.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/crawl-ref/source/fixvec.h b/crawl-ref/source/fixvec.h index 77a841ec30..476eded773 100644 --- a/crawl-ref/source/fixvec.h +++ b/crawl-ref/source/fixvec.h @@ -47,6 +47,11 @@ public: init(def); } + FixedVector(TYPE value0, TYPE value1, ...); + // Allows for something resembling C array initialization, eg + // instead of "int a[3] = {0, 1, 2}" you'd use "FixedVector<int, 3> + // a(0, 1, 2)". Note that there must be SIZE arguments. + //----------------------------------- // API // @@ -89,6 +94,24 @@ protected: // Outlined Methods // ========================================================================== template <class TYPE, int SIZE> +FixedVector<TYPE, SIZE>::FixedVector(TYPE value0, TYPE value1, ...) +{ + mData[0] = value0; + mData[1] = value1; + + va_list ap; + va_start(ap, value1); // second argument is last fixed parameter + + for (int index = 2; index < SIZE; index++) + { + TYPE value = va_arg(ap, TYPE); + mData[index] = value; + } + + va_end(ap); +} + +template <class TYPE, int SIZE> void FixedVector<TYPE, SIZE>::init(const TYPE& def) { for (int i = 0; i < SIZE; ++i) |