4ビットchar型をmapのキーとしたmapを参照できない
C++でchar型マップを作成しました。しかし参照できません。
#include<iostream>
#include<map>
using namespace std;
const map<char, char> M{
{0x0, 0xc},
{0x1, 0x5},
{0x2, 0x6},
{0x3, 0xb},
{0x4, 0x9},
{0x5, 0x0},
{0x6, 0xa},
{0x7, 0xd},
{0x8, 0x3},
{0x9, 0xe},
{0xa, 0xf},
{0xb, 0x8},
{0xc, 0x4},
{0xd, 0x7},
{0xe, 0x1},
{0xf, 0x2}
};
int main(){
cout << static_cast<bitset<4> > (M[0x0]) << endl;
return 0;
}
下記エラーが出てしまいます。
test.cpp:46:40: error: no viable overloaded operator[] for type 'const map<char, char>'
cout << static_cast<bitset<4> > (M[0x0]) << endl;
^~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/map:1006:18: note: candidate function not viable: 'this' argument has type
'const map<char, char>', but method is not marked const
mapped_type& operator[](const key_type& __k);
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/map:1008:18: note: candidate function not viable: 'this' argument has type
'const map<char, char>', but method is not marked const
mapped_type& operator[](key_type&& __k);
^
1 error generated.
このようなmapを使うことはできますか。