22
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

std::to_stringやstd::stoi、std::stofがAndroidで使えない時は・・・

Posted at

Cocos2d-x v3系でもAndroidではto_stringやstd::stoi、std::stofが使えません。
AndroidのNDKにこれらがまだ対応していないことが原因のようです。

XcodeでCocosのコードを検索してみると・・・
Cocos2d-xのコード中にこんな表現がありました。

スクリーンショット 2015-03-27 18.17.09.png

###std::to_string is not supported on android, using std::stringstream instead.###

###「std::to_stringはAndroidではサポートされていないから、変わりにstd::stringstreamを使ってね。」###
つまりCocos開発者もAndroidでは使えないと言ってます。

##結論:std::stringstreamを使いましょう。
こんな感じで。

    int i = 10;
    std::stringstream name;
    name << "name_" << i;
    std::string myName = name.str(); //name_10
22
19
5

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?