0
文字列を実装しようとしています。文字列を小文字に変換したいので、boost::to_lower_copy(m_s)
と呼ばれます。実際にはm_s
はstd::string
です。私の質問は、to_lower_copy()
でreturn {boost::to_lower_copy(m_s)};
がどのように機能するかです。どのようにString型を返すことができますか? ありがとうございました。"return {...};"はC++ 11でどのように動作しますか?
class String {
std::string m_s;
public:
String(const std::string s) : m_s(s) { }
String to_lower_copy() const {
return {boost::to_lower_copy(m_s)};
}
};
'return {...}'は 'std :: string {...}'を呼び出し、新しく構築された文字列を返します。これは、関数がstd :: stringを返す必要があることをコンパイラーが認識しているためです。 –
@RichardCritten、なぜコメントに答えますか?あなたはあなたのコメントを回答に変換する必要があります。 –
@RichardCritten 'String'を意味しましたか? – LogicStuff