std::vector<VARIANT> varVect
Hi all !
I kannot do a VARIANT (or better _variant_t) vector. This code:
#include <vector>
typedef std::vector<VARIANT> VariantVECTOR;
class MyClass
{
public:
MyClass(){;}
virtual ~MyClass(){;}
private:
VariantVECTOR myVarVect;
};
gives this compiler error:
C:\Programme\DevStudio\VC\INCLUDE\xutility(45) : error C2678: binary '<' : 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
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*).
Re: std::vector<VARIANT> varVect
Subject: Re: std::vector<VARIANT> 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 <() (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 < () 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