When attempting to convert a std::string
to an Aws::String
using the following code:
std::string s("Johnny is cool");
Aws::String aws_s(s);
And I get the following error:
error: no matching function for call to ‘std::__cxx11::basic_string<char, std::char_traits<char>, Aws::Allocator<char> >::basic_string(const string&)’
From https://github.com/aws/aws-sdk-cpp/issues/416. Thanks Bu11etmagnet!
If you have a std::string
you want to pass to an Aws function, construct an Aws::String
from it
std::string s{"whatever"};
Aws::String aws_s(s.c_str(), s.size());
Aws::SomeFunction(aws_s);
If you got an Aws::String from an Aws function, construct a std::string from it:
Aws::String const& aws_s = Aws::SomeFunction();
std::string s(aws_s.c_str(), aws_s.size());
Both of these perform a copy of the string content, unfortunately.
Aws::String aws_s(std_string.c_str())
would measure the string length with strlen(), an information already contained in the std::string object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With