The recent version of C++ has added a some new keywords e.g. decltype etc..
I want to highlight them in my report.
I saw this post but it didn't work for me.
Extend a language with additional keywords?
So i added the following code
\usepackage{listings}
\lstset{emph={%
decltype%
},emphstyle={\color{black}}%
}
But then I got the error message:
undefined control sequence decltype
when used in the following way:
\begin{lstlisting}
auto f(T1 X, T2 Y) ->
decltype(X<Y)
{}
\end{lstlisting}
Best Answer
Expanding on to Stephan's post. To make it easy to add keywords to emphasize, it is always best to define a new environment and a command such a
\emphasis
. Here is a MWE.