+/** Helper template to allow initialization of containers via an overloaded
+ * comma operator (idea stolen from Blitz++). */
+template <typename T, typename STLT>
+class container_init {
+public:
+ container_init(STLT & s) : stlt(s) {}
+
+ container_init<T, STLT> operator,(const T & x)
+ {
+ stlt.push_back(x);
+ return container_init<T, STLT>(stlt);
+ }
+
+ // The following specializations produce much tighter code than the
+ // general case above
+
+ container_init<T, STLT> operator,(int x)
+ {
+ stlt.push_back(x);
+ return container_init<T, STLT>(stlt);
+ }
+
+ container_init<T, STLT> operator,(unsigned int x)
+ {
+ stlt.push_back(x);
+ return container_init<T, STLT>(stlt);
+ }
+
+ container_init<T, STLT> operator,(long x)
+ {
+ stlt.push_back(x);
+ return container_init<T, STLT>(stlt);
+ }
+
+ container_init<T, STLT> operator,(unsigned long x)
+ {
+ stlt.push_back(x);
+ return container_init<T, STLT>(stlt);
+ }
+
+ container_init<T, STLT> operator,(double x)
+ {
+ stlt.push_back(x);
+ return container_init<T, STLT>(stlt);
+ }
+
+ container_init<T, STLT> operator,(const symbol & x)
+ {
+ stlt.push_back(T(x));
+ return container_init<T, STLT>(stlt);
+ }
+
+private:
+ container_init();
+ STLT & stlt;
+};
+