MSVCRT std::vector 新しいページはコチラ
提供: yonewiki
(→メンバ関数 assign) |
(→メンバ関数 assign) |
||
76行: | 76行: | ||
− | [[Windows#MSVC Runtimeリファレンス|MSVC Runtimeリファレンス]]に戻る | + | === '''メンバ関数 emplace_back''' === |
+ | *<span style = "background:linear-gradient(transparent 75%, #cab8d9 75%); font-weight:bold; "><span style="color:deeppink;">void</span> <span style="color:blue;">obj.emplace_back</span>(<span style="color:deeppink;">TypeTemplate(vector<TypeTemplate>)</span>);</span> | ||
+ | *<span style = "background:linear-gradient(transparent 75%, #cab8d9 75%); font-weight:bold; "><span style="color:deeppink;">void</span> <span style="color:blue;">obj.emplace_back</span>(<span style="color:deeppink;">InputIterator</span> first, <span style="color:deeppink;">InputIterator</span> last);</span> | ||
+ | *<span style = "background:linear-gradient(transparent 75%, #cab8d9 75%); font-weight:bold; "><span style="color:deeppink;">void</span> <span style="color:blue;">obj.emplace_back</span>(<span style="color:deeppink;">Initializer_list<TypeTemplate></span>);</span> | ||
+ | |||
+ | TypeTemplate(vector<TypeTemplate>)はvectorの型テンプレートで型を生成するコンストラクタによって初期化形式である必要があります。?何を言っているの? | ||
+ | |||
+ | 例えばvectorはvector<std::string> obj;のようにstd::string型を定義した場合。objはsdt::string型が順序を持って連続するような値になります。そうすると以下の例のように定義します。 | ||
+ | |||
+ | sample.cpp | ||
+ | <syntaxhighlight2 lang="cpp"> | ||
+ | #include<cstidio> | ||
+ | #include<vector> | ||
+ | |||
+ | int main(int iArgc char** cArgv){ | ||
+ | std::vector<std::string> objVectorStdString_data; | ||
+ | |||
+ | obj.emplase_back(std::string("Hello! VectorDataString!")); | ||
+ | //std::stringのコンストラクタでstd::string型そのものが引数になる。 | ||
+ | } | ||
+ | </syntaxhighlight2> | ||
+ | |||
+ | [[[Windows#MSVC Runtimeリファレンス|MSVC Runtimeリファレンス]]に戻る |