From 4d51fb8132bcf2961b52cb2f45663ddaf8406db2 Mon Sep 17 00:00:00 2001 From: nojhan Date: Wed, 22 Apr 2020 07:58:52 +0200 Subject: [PATCH] feat: initialization of eoVector from std::vector Useful to brace-init hard-coded vectors. --- eo/src/eoInt.h | 11 +++++++++-- eo/src/eoVector.h | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/eo/src/eoInt.h b/eo/src/eoInt.h index 8dc318e2c..3975743e8 100644 --- a/eo/src/eoInt.h +++ b/eo/src/eoInt.h @@ -45,8 +45,15 @@ template class eoInt: public eoVector * @param size Size of the std::vector * @param value fill the vector with this value */ - eoInt(unsigned size = 0, int value = 0): - eoVector(size, value) {} + eoInt(unsigned size = 0, int value = 0) : + eoVector(size, value) + {} + + /** Constructor copying from a vector (or an initialization list). + */ + eoInt(std::vector vec) : + eoVector(vec) + {} /// My class name. virtual std::string className() const diff --git a/eo/src/eoVector.h b/eo/src/eoVector.h index bdedd5e94..7bf28eaf4 100644 --- a/eo/src/eoVector.h +++ b/eo/src/eoVector.h @@ -73,6 +73,12 @@ public: : EO(), std::vector(_size, _value) {} + /** Constructor copying from a vector (or an initialization list). + */ + eoVector( std::vector vec ) + : EO(), std::vector(vec) + {} + /// copy ctor abstracting from the FitT template eoVector(const eoVector& _vec) : std::vector(_vec)