以下の内容はhttps://faithandbrave.hateblo.jp/entry/20071127/1196154125より取得しました。


boost::assign使ってみた

#include <iostream>
#include <vector>
#include <shand/foreach.hpp>
#include <boost/assign/std/vector.hpp>

using namespace std;
using namespace boost::assign;

int main()
{
    vector<int> v;

    v += 3, 1, 4; // !!!

    foreach (int value, v)
        cout << value << endl;

    return 0;
}


+=の中ではpush_backやってて、戻り値にlist_inserterとかいうのを使ってるのでカンマ区切りできるんだってさ


念のためboost::assign使わないコード

#include <iostream>
#include <vector>
#include <shand/foreach.hpp>

using namespace std;

int main()
{
    vector<int> v;

    v.push_back(3);
    v.push_back(1);
    v.push_back(4);

    foreach (int value, v)
        cout << value << endl;

    return 0;
}


ちなみに↑のコードで使っているforeach.hppはこれ





以上の内容はhttps://faithandbrave.hateblo.jp/entry/20071127/1196154125より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14