CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 1999
    Posts
    13

    std::vector<VARIANT> varVect

    Hi all !

    I kannot do a VARIANT (or better _variant_t) vector. This code:
    #include &lt;vector&gt;
    typedef std::vector&lt;VARIANT&gt; VariantVECTOR;

    class MyClass
    {
    public:
    MyClass(){;}
    virtual ~MyClass(){;}

    private:
    VariantVECTOR myVarVect;
    };

    gives this compiler error:

    C:\Programme\DevStudio\VC\INCLUDE\xutility(45) : error C2678: binary '&lt;' : no operator defined which takes a left-hand operand of type 'const struct tagVARIANT' (or there is no acceptable conversion)

    Please help !

    Thanks in advance !

    Emanuil Achim


  2. #2
    Join Date
    May 1999
    Location
    Antwerp, Belgium
    Posts
    136

    Re: std::vector<VARIANT> varVect

    I think this is because VARIANT hasn't got a copy constructor. You can avoid this by making a vector of pointers to a VARIANT (VARIANT*).


  3. #3
    Join Date
    Apr 1999
    Posts
    383

    Re: std::vector<VARIANT> varVect

    Subject: Re: std::vector&lt;VARIANT&gt; varVect

    That code should be OK - it works in VC++6.0 SP3. What version of VC++ are you using, and what service packs?

    It's complaining that there is no operator &lt;() (less than) for VARIANT). You should expect to get this error if you use sorting or comparison algorithms, because they generally require the contained object to have an operator &lt; () defined, and VARIANT does not (you could provide one, but it wouldn't be easy, as VARIANT can 'be' so many types!).

    If I remember right, MSVC++ 5.0 had some oddities in the STL containers where they incorrectly required more comparison operators than they should, so maybe that's the problem...

    Using VARIANT pointers is a reasonable work-around, though.

    Dave




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured