D
Dilip
Howdy
I have code similar to this in my project:
Note: BSTR is an abomination conjured up some disturbed person in the
COM world. BSTR strings must be allocated/deallocated using the
SysAllocString/SysFreeString Windows APIs.
typedef struct tagMyStruct
{
BSTR somestring;
BSTR someotherstring;
} MyStruct;
vector<MyStruct> my_struct;
over the course of my app, I allocate the BSTRs inside MyStruct and
stuff them into the vector.
When the time comes to get rid of them I was wondering if there is a
way to free the memory pointed to by the BSTR's in every MyStruct
instance inside the vector using a _single_ STL algorithm call?
Currently I use a combination of for_each (with a predicate to delete
the BSTRs) followed by a call to my_struct.erase(mystruct.begin(),
mystruct.end()).
There must be a better way to do this, right?
I looked up remove and remove_if, but they don't seem to be right for
my situation...
I have code similar to this in my project:
Note: BSTR is an abomination conjured up some disturbed person in the
COM world. BSTR strings must be allocated/deallocated using the
SysAllocString/SysFreeString Windows APIs.
typedef struct tagMyStruct
{
BSTR somestring;
BSTR someotherstring;
} MyStruct;
vector<MyStruct> my_struct;
over the course of my app, I allocate the BSTRs inside MyStruct and
stuff them into the vector.
When the time comes to get rid of them I was wondering if there is a
way to free the memory pointed to by the BSTR's in every MyStruct
instance inside the vector using a _single_ STL algorithm call?
Currently I use a combination of for_each (with a predicate to delete
the BSTRs) followed by a call to my_struct.erase(mystruct.begin(),
mystruct.end()).
There must be a better way to do this, right?
I looked up remove and remove_if, but they don't seem to be right for
my situation...