CPPPROGLIB Telegram 6014
🍓 Команда дня: std::apply (C++17)

Вызов функций с аргументами из tuple требует распаковки вручную.


До:

cppauto args = std::make_tuple(1, 2.5, "hello");

// Как передать все аргументы в функцию?
func(std::get<0>(args), std::get<1>(args), std::get<2>(args));



После:
cppauto args = std::make_tuple(1, 2.5, "hello");
std::apply(func, args); // Автоматическая распаковка!



🌳 Практические примеры:

• Вызов конструкторов: std::apply([](auto... args){ return T{args...}; }, tuple)
• Функциональное программирование
• Рефлексия: вызов методов с динамическими аргументами


👁 Используете std::apply для elegant кода?

Библиотека C/C++ разработчика

#буст
Please open Telegram to view this post
VIEW IN TELEGRAM
14👍6



tgoop.com/cppproglib/6014
Create:
Last Update:

🍓 Команда дня: std::apply (C++17)

Вызов функций с аргументами из tuple требует распаковки вручную.


До:

cppauto args = std::make_tuple(1, 2.5, "hello");

// Как передать все аргументы в функцию?
func(std::get<0>(args), std::get<1>(args), std::get<2>(args));



После:
cppauto args = std::make_tuple(1, 2.5, "hello");
std::apply(func, args); // Автоматическая распаковка!



🌳 Практические примеры:

• Вызов конструкторов: std::apply([](auto... args){ return T{args...}; }, tuple)
• Функциональное программирование
• Рефлексия: вызов методов с динамическими аргументами


👁 Используете std::apply для elegant кода?

Библиотека C/C++ разработчика

#буст

BY Библиотека C/C++ разработчика | cpp, boost, qt


Share with your friend now:
tgoop.com/cppproglib/6014

View MORE
Open in Telegram


Telegram News

Date: |

To delete a channel with over 1,000 subscribers, you need to contact user support While some crypto traders move toward screaming as a coping mechanism, many mental health experts have argued that “scream therapy” is pseudoscience. Scientific research or no, it obviously feels good. ZDNET RECOMMENDS A Hong Kong protester with a petrol bomb. File photo: Dylan Hollingsworth/HKFP. For crypto enthusiasts, there was the “gm” app, a self-described “meme app” which only allowed users to greet each other with “gm,” or “good morning,” a common acronym thrown around on Crypto Twitter and Discord. But the gm app was shut down back in September after a hacker reportedly gained access to user data.
from us


Telegram Библиотека C/C++ разработчика | cpp, boost, qt
FROM American