Consider fallowing peace of code:
using trading_day = std::pair<int, bool>;
using fun_intersection = vector<pair<int, bool>>;
double stock_trading_simulation(const fun_vals& day_value, fun_intersection& trade_days, int base_stock_amount = 1000)
{
int act_stock_amount = base_stock_amount;
for(auto trade : trade_days)
{
if (trade.second == BUY)// how to change it to trade.action?
{
}
else
{
}
}
}
What I would like to do is to instead of referring to pair
as .first
and .second
I would want to refer to them as .day and .action, is it possible in any practical way to use c++17 or earlier versions?
I tried doing something like this:
for(auto[day,action] trade : trade_days)
however it does not compile.