I saw a code that used narrow_cast
like this
int num = narrow_cast<int>(26.72);
cout << num;
The problem is my compiler said:
'narrow_cast' was not decleared in this scope.
Am I supposed to define narrow_cast
myself or am I using it the wrong way or is there nothing like narrow_cast
?
narrow_cast
of gsl is really astatic_cast
. But it is more explicit and you can later search for it. You can check the implementation yourself:narrow_cast
is not a part of the standard C++. You need gsl to compile and run this. You are probably missing that and that is why it is not compiling.