\doxysection{unique\+\_\+id.\+h}
\hypertarget{unique__id_8h_source}{}\label{unique__id_8h_source}
\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{comment}{//\ =====================================================================================================================}}
\DoxyCodeLine{00002\ \textcolor{comment}{//\ \ open-\/cpp-\/utils,\ an\ open-\/source\ cpp\ library\ with\ data\ structures\ that\ extend\ the\ STL.}}
\DoxyCodeLine{00003\ \textcolor{comment}{//\ \ Copyright\ (C)\ 2024\ \ Medusa\ Slockbower}}
\DoxyCodeLine{00004\ \textcolor{comment}{//}}
\DoxyCodeLine{00005\ \textcolor{comment}{//\ \ This\ program\ is\ free\ software:\ you\ can\ redistribute\ it\ and/or\ modify}}
\DoxyCodeLine{00006\ \textcolor{comment}{//\ \ it\ under\ the\ terms\ of\ the\ GNU\ General\ Public\ License\ as\ published\ by}}
\DoxyCodeLine{00007\ \textcolor{comment}{//\ \ the\ Free\ Software\ Foundation,\ either\ version\ 3\ of\ the\ License,\ or}}
\DoxyCodeLine{00008\ \textcolor{comment}{//\ \ (at\ your\ option)\ any\ later\ version.}}
\DoxyCodeLine{00009\ \textcolor{comment}{//}}
\DoxyCodeLine{00010\ \textcolor{comment}{//\ \ This\ program\ is\ distributed\ in\ the\ hope\ that\ it\ will\ be\ useful,}}
\DoxyCodeLine{00011\ \textcolor{comment}{//\ \ but\ WITHOUT\ ANY\ WARRANTY;\ without\ even\ the\ implied\ warranty\ of}}
\DoxyCodeLine{00012\ \textcolor{comment}{//\ \ MERCHANTABILITY\ or\ FITNESS\ FOR\ A\ PARTICULAR\ PURPOSE.\ \ See\ the}}
\DoxyCodeLine{00013\ \textcolor{comment}{//\ \ GNU\ General\ Public\ License\ for\ more\ details.}}
\DoxyCodeLine{00014\ \textcolor{comment}{//}}
\DoxyCodeLine{00015\ \textcolor{comment}{//\ \ You\ should\ have\ received\ a\ copy\ of\ the\ GNU\ General\ Public\ License}}
\DoxyCodeLine{00016\ \textcolor{comment}{//\ \ along\ with\ this\ program.\ \ If\ not,\ see\ <https://www.gnu.org/licenses/>.}}
\DoxyCodeLine{00017\ \textcolor{comment}{//\ =====================================================================================================================}}
\DoxyCodeLine{00018\ }
\DoxyCodeLine{00019\ \textcolor{preprocessor}{\#ifndef\ OPEN\_CPP\_UTILS\_UNIQUE\_ID\_H}}
\DoxyCodeLine{00020\ \textcolor{preprocessor}{\#define\ OPEN\_CPP\_UTILS\_UNIQUE\_ID\_H}}
\DoxyCodeLine{00021\ }
\DoxyCodeLine{00022\ \textcolor{preprocessor}{\#include\ <cstdint>}}
\DoxyCodeLine{00023\ }
\DoxyCodeLine{00024\ \textcolor{keyword}{namespace\ }open\_cpp\_utils}
\DoxyCodeLine{00025\ \{}
\DoxyCodeLine{00026\ }
\DoxyCodeLine{00027\ \textcolor{comment}{//\ Internal\ function\ for\ incrementing\ an\ id\ associated\ with\ a\ type}}
\DoxyCodeLine{00028\ \textcolor{keyword}{template}<\textcolor{keyword}{typename}\ Base>\ uint64\_t\ \_increment\_id()}
\DoxyCodeLine{00029\ \{}
\DoxyCodeLine{00030\ \ \ \ \ \textcolor{keyword}{static}\ uint64\_t\ current\ =\ 0;}
\DoxyCodeLine{00031\ \ \ \ \ \textcolor{keywordflow}{return}\ current++;}
\DoxyCodeLine{00032\ \}}
\DoxyCodeLine{00033\ }
\DoxyCodeLine{00047\ \textcolor{keyword}{template}<\textcolor{keyword}{typename}\ Base,\ \textcolor{keyword}{typename}\ Type>\ uint64\_t\ unique\_id()}
\DoxyCodeLine{00048\ \{}
\DoxyCodeLine{00049\ \ \ \ \ \textcolor{keyword}{static}\ \textcolor{keywordtype}{bool}\ initialized\ =\ \textcolor{keyword}{false};}
\DoxyCodeLine{00050\ \ \ \ \ \textcolor{keyword}{static}\ uint64\_t\ \textcolor{keywordtype}{id}\ =\ 0;}
\DoxyCodeLine{00051\ }
\DoxyCodeLine{00052\ \ \ \ \ \textcolor{keywordflow}{if}(initialized)\ \textcolor{keywordflow}{return}\ id;}
\DoxyCodeLine{00053\ \ \ \ \ initialized\ =\ \textcolor{keyword}{true};}
\DoxyCodeLine{00054\ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keywordtype}{id}\ =\ \_increment\_id<Base>();}
\DoxyCodeLine{00055\ \}}
\DoxyCodeLine{00056\ }
\DoxyCodeLine{00057\ \}}
\DoxyCodeLine{00058\ }
\DoxyCodeLine{00059\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{//\ OPEN\_CPP\_UTILS\_UNIQUE\_ID\_H}}

\end{DoxyCode}
