conanaws-sdk-cpp

Why is Aws::String not extending std::string


We previously built aws-sdk-cpp locally and designed a library around it. Now I'm upgrading to use Conan provided aws-sdk-cpp instead of a locally built one, but I'm getting errors from our library.

I call AWS functions such as the following,

std::string src_bucket;
DeleteObject
// ...

obj.WithBucket(src_bucket).WithDelete(std::move(del));

but I get errors like this.

error: no matching function for call to 'Aws::S3::Model::DeleteObjectsRequest::WithBucket(const string&)`.

Has this function call changed to now allow std::string? Is there a way to make AWS methods accept std::string?


Solution

  • Is there a way to make AWS methods accept std::string?

    Yes. These functions accept std::string if custom memory management is disabled:

    If the compile-time constant is enabled (on), the types resolve to STL types with a custom allocator connected to the AWS memory system.

    If the compile-time constant is disabled (off), all Aws::* types resolve to the corresponding default std::* type.

    It looks like the former is what you get, and the latter is what you expect - perhaps you've switched from linking the SDK statically (default off) to linking the SDK dynamically (default on)?

    In any case, you'll either have to somehow build the SDK with custom memory management disabled, use types like Aws::String yourself, or convert between Aws::String and std::string as needed.