When calling a function that expects a BSTR it'd be nice to be able to write something like:
iFoo->function( bs"HELLO" );
However the only workaround I'm aware of is to use a wrapper that calls SysAllocString
etc., e.g.:
iFoo->function( WideString(L"HELLO").c_bstr() );
which is kind of ugly. Is there actually such an option to create a BSTR
literal?
Motivation: easier-to-read code, and faster runtime performance by avoiding an allocation and deallocation.
Clarification: I am only talking about situations where the caller (i.e. us) has ownership of the BSTR, for example: calling a function that takes a BSTR [in]
parameter. Of course, it would be silly to supply a pointer to a BSTR literal to a function which will go on to try and free the string.