Nope, that is not the correct way to do it (if I got you).
Namely, he type of the
map
is incorrect, it should store an array of
int16_t
(instead of a single
int16_t
). I'm showing you a working example
#include <cstdint>
#include <iostream>
#include <array>
#include <map>
using namespace std;
constexpr size_t ArraySize = 10;
static const array<int16_t, ArraySize> Val =
{
0xC18, 0xC23, 0xC26, 0xC29, 0xC2C, 0xC37, 0xC3A, 0xC3D, 0xC40, 0xC4B,
};
static const array<int16_t, ArraySize> Val_ =
{
0x040, 0x043, 0x046, 0x04A, 0x04D, 0x050, 0x053, 0x056, 0x05A, 0x05D,
};
using fruit = std::map<std::string, array<int16_t, ArraySize > >;
static const fruit red=
{
{"step1", Val},
{"step2",Val_},
};
int main()
{
std::string step_;
size_t b;
cout<<"enter step"<<endl;
cin>>step_;
cout<<"enter number"<<endl;
cin>>b;
auto it = red.find(step_);
if ( it != red.end())
{
cout << hex << it->second.at(b) << endl;
}
}