I’ve been attempting to use a custom SecureAllocator with basic_string and the STL containers but I’m having very little luck.
typedef std::basic_string< char, std::char_traits< char >, SecureAllocator< char > > SecureString;
SecureString value = "hello, world!";
vector< SecureString > collection;
collection.push_back( value );
In file included from /Users/bcrowhurst/source/utility/string_impl.cpp:31:
In file included from /Users/bcrowhurst/build/../source/utility/string_impl.h:31:
/usr/bin/../lib/c++/v1/string:2162:19: error: invalid operands to binary expression ('allocator_type' (aka 'SecureAllocator<char>') and 'allocator_type')
if (__alloc() != __str.__alloc())
~~~~~~~~~ ^ ~~~~~~~~~~~~~~~
Envirnoment
Mac OSX Lion
Apple clang version 3.1 (tags/Apple/clang-318.0.61) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.0
Thread model: posix
You have to implement comparison operators for your allocator type, telling if they are ‘equivalent’ so they can be used interchangably (or not).
The requirement for comparing two allocators
a1 == a2isand for
a1 != a2