Merge pull request #18196 from mpashchenkov:mp/garray-initialization

[G-API]: Add GArray initialization support

* Added GArray initialization (CONST_VALUE, GScalar analog) and test for this

* Whitespaces

* And one more space

* Trailing whitespace

* Test name changed. Build with magic commands.

* GArray works with rvalue initialization

* Code cleanup

* Ternary operator in the initialization list.
This commit is contained in:
Maxim Pashchenkov
2020-09-18 16:06:23 +03:00
committed by GitHub
parent a07f064e50
commit 830d8d6b75
7 changed files with 78 additions and 5 deletions
+9 -4
View File
@@ -80,6 +80,7 @@ namespace detail
protected:
GArrayU(); // Default constructor
GArrayU(const detail::VectorRef& vref); // Constant value constructor
template<class> friend class cv::GArray; // (available to GArray<T> only)
void setConstructFcn(ConstructVec &&cv); // Store T-aware constructor
@@ -328,6 +329,14 @@ namespace detail
template<typename T> class GArray
{
public:
// Host type (or Flat type) - the type this GArray is actually
// specified to.
using HT = typename detail::flatten_g<typename std::decay<T>::type>::type;
explicit GArray(const std::vector<HT>& v) // Constant value constructor
: m_ref(detail::GArrayU(detail::VectorRef(v))) { putDetails(); }
explicit GArray(std::vector<HT>&& v) // Move-constructor
: m_ref(detail::GArrayU(detail::VectorRef(std::move(v)))) { putDetails(); }
GArray() { putDetails(); } // Empty constructor
explicit GArray(detail::GArrayU &&ref) // GArrayU-based constructor
: m_ref(ref) { putDetails(); } // (used by GCall, not for users)
@@ -335,10 +344,6 @@ public:
detail::GArrayU strip() const { return m_ref; }
private:
// Host type (or Flat type) - the type this GArray is actually
// specified to.
using HT = typename detail::flatten_g<typename std::decay<T>::type>::type;
static void VCTor(detail::VectorRef& vref) {
vref.reset<HT>();
vref.storeKind<HT>();