B
Brian
In this thread,
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/f4a8b07d4aa18d73#
I recently posted this:
template <typename B>
void
Receive(B* buf, vector<deque<lil_string> >& abt1)
{
uint32_t headCount[2];
buf->Give(headCount[0]);
abt1.reserve(abt1.size() + headCount[0]);
for (; headCount[0] > 0; --headCount[0]) {
deque<lil_string> rep4;
buf->Give(headCount[1]);
for (; headCount[1] > 0; --headCount[1]) {
lil_string rep5(buf);
rep4.push_back(std::move(rep5));
}
abt1.push_back(std::move(rep4));
}
}
I have a question related to the inner loop and emplace. I thought
the correct way to do things would be like this:
for (; headCount[1] > 0; --headCount[1]) {
rep4.emplace_back(buf);
}
However, some documentation I read --
http://msdn.microsoft.com/en-us/library/dd647620.aspx
suggests that it should be:
for (; headCount[1] > 0; --headCount[1]) {
rep4.emplace_back(lil_string(buf));
}
I'm not sure if both are considered correct or just one is.
Does the latter approach try to use a lil_string move
constructor? I thought emplace (in the former snippet)
would efficiently add an object to the container even if
the type doesn't have a move constructor. That seems
like a big advantage to me. Thanks in advance.
Brian Wood
http://webEbenezer.net
(651) 251-9384
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/f4a8b07d4aa18d73#
I recently posted this:
template <typename B>
void
Receive(B* buf, vector<deque<lil_string> >& abt1)
{
uint32_t headCount[2];
buf->Give(headCount[0]);
abt1.reserve(abt1.size() + headCount[0]);
for (; headCount[0] > 0; --headCount[0]) {
deque<lil_string> rep4;
buf->Give(headCount[1]);
for (; headCount[1] > 0; --headCount[1]) {
lil_string rep5(buf);
rep4.push_back(std::move(rep5));
}
abt1.push_back(std::move(rep4));
}
}
I have a question related to the inner loop and emplace. I thought
the correct way to do things would be like this:
for (; headCount[1] > 0; --headCount[1]) {
rep4.emplace_back(buf);
}
However, some documentation I read --
http://msdn.microsoft.com/en-us/library/dd647620.aspx
suggests that it should be:
for (; headCount[1] > 0; --headCount[1]) {
rep4.emplace_back(lil_string(buf));
}
I'm not sure if both are considered correct or just one is.
Does the latter approach try to use a lil_string move
constructor? I thought emplace (in the former snippet)
would efficiently add an object to the container even if
the type doesn't have a move constructor. That seems
like a big advantage to me. Thanks in advance.
Brian Wood
http://webEbenezer.net
(651) 251-9384