# Beamer - Sections inside TOC without frames for it

I am trying to use a section at the end of a presentation without any frames for it as shown in the following MWE:

\documentclass{beamer}

\begin{document}

\begin{frame}{TOC}
\tableofcontents
\end{frame}

\section{The first section}

\begin{frame}
Some text.
\end{frame}

\section{The second section}

\end{document}


This produces a TOC which only consists of the The first section. I want to get a TOC which additionally shows The second section.

I could use a dummy frame for the second section of course, but is there any way to avoid adding a frame for the second section?

The problem is that without another page following, the content is not written to the toc file. You can circumvent the problem like this:

\documentclass{beamer}

\makeatletter
\let\protect\@unexpandable@protect
\immediate\write\@auxout{\noexpand\@writefile{toc}{#1}}%
}}
\makeatother

\begin{document}

\begin{frame}{TOC}
\tableofcontents
\end{frame}

\section{The first section}
\subsection{blub}

\begin{frame}
Some text.
\end{frame}

\section{The first section}
\subsection{blub}

\begin{frame}
Some text.
\end{frame}