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: |

With Bitcoin down 30% in the past week, some crypto traders have taken to Telegram to “voice” their feelings. On Tuesday, some local media outlets included Sing Tao Daily cited sources as saying the Hong Kong government was considering restricting access to Telegram. Privacy Commissioner for Personal Data Ada Chung told to the Legislative Council on Monday that government officials, police and lawmakers remain the targets of “doxxing” despite a privacy law amendment last year that criminalised the malicious disclosure of personal information. A new window will come up. Enter your channel name and bio. (See the character limits above.) Click “Create.” Ng, who had pleaded not guilty to all charges, had been detained for more than 20 months. His channel was said to have contained around 120 messages and photos that incited others to vandalise pro-government shops and commit criminal damage targeting police stations. Ng was convicted in April for conspiracy to incite a riot, public nuisance, arson, criminal damage, manufacturing of explosives, administering poison and wounding with intent to do grievous bodily harm between October 2019 and June 2020.
from us


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