[xsd-users] Howto avoid slicing with xsd-types to std::string

Tempelaar E. (Erik) Erik.Tempelaar at vanoord.com
Wed Oct 13 01:55:06 EDT 2021


Thank you for getting back to me so soon.

Here's the exact message for the code below:

" Use pointer or reference to avoid slicing from "string<char, xsd::cxx::tree::simple_type<char, xsd::cxx::tree::_type>>" to "basic_string<char>"

    if (cfg->Configuration().ProjectFolder().present()) {

      m_projectFolder = cfg->Configuration().ProjectFolder().get();


with: m_projectFolder:
std::string m_projectFolder{""};

<xsd:element name="ProjectFolder" type="xsd:string" minOccurs="0">
</xsd:element>


But there's others like this one (not only the optionals), i.e.:
"Use pointer or reference to avoid slicing from "Title_t" to "basic_string<char>"

Best regards,
Erik

-----Original Message-----
From: Boris Kolpackov <boris at codesynthesis.com>
Sent: 12 October 2021 15:35
To: Tempelaar E. (Erik) <Erik.Tempelaar at vanoord.com>
Cc: xsd-users at codesynthesis.com
Subject: Re: [xsd-users] Howto avoid slicing with xsd-types to std::string

Tempelaar E. (Erik) <Erik.Tempelaar at vanoord.com> writes:

> As a result we get warnings for code that interacts with xsd-generated
> types with assignments where the resulting type is simply a std::string.

Can you show an example of the code that produces such a warning and the warning diagnostics that you are getting for it?




Disclaimer: This mail transmission and any attached files are confidential and are intended for the addressee only. If you are not the person or organization to whom it is addressed, you must not copy, disclose, distribute or take any action in reliance upon it. If you have received this message in error, please contact the sender by email and delete all copies of this message and all copies of any attached files.



More information about the xsd-users mailing list