Staying away from LaTeX for barely more than 2 years has devastating effects.
I think once I knew how to protect this stuff, but I have no idea now.
I defined the newcommand below to be faster in writing C++ code inline (and I have a similar macro for other languages). However, it looks like it doesn't really like the # of include statements:
\documentclass{article}
\usepackage{minted}
\newcommand{\cpp}[1]{\mintinline{c++}{#1}}
\begin{document}
\noindent
\mintinline{c++}{#include <iostream>} % ok
\
\cpp{#include <iostream>} % renders as ##include <iostream>
\end{document}
#safe but that can not work as it has already been read by\cppas a special character before minted sees it – David Carlisle Feb 28 '21 at 17:12\newcommand:\newcommand{\cpp}{\mintinline{c++}}might work. (Of course these kind of tricks making the "verbatim" argument explicit do not always work.) – moewe Feb 28 '21 at 17:13\newmintinlineto define your own\mintinline-like command directly. – moewe Feb 28 '21 at 17:18