Код: Выделить всё
template
void foo_collection(Collection&& c, Item && i) {
foo(std::forward(c), std::forward(i));
}
Код: Выделить всё
template
void foo_collection(Collection&& c, Item&& i) {
foo(FWD(c), FWD(i));
}
Код: Выделить всё
#define FWD(v) \
std::forward< \
typename std::remove_const::type>(v)
Код: Выделить всё
void foo(int& a) { cout
Подробнее здесь: [url]https://stackoverflow.com/questions/31253475/is-there-a-way-to-write-a-macro-to-do-perfect-forwarding-using-only-the-variable[/url]
Мобильная версия