So I'm following a C++/SDL2 programming tutorial series for 2D gaming. I was following along on this video and he wrote this bit of code.
using ComponentID = std::size_t;
inline ComponentID getComponentID()
{
static ComponentID lastID = 0;
return lastID++;
}
template <typename T> inline ComponentID getComponentID() noexcept
{
static ComponentID typeID = getComponentID();
//typeID below is being used like a function???
return typeID(); //<- error and won't compile, I believe this was a typo
}
I don't understand why template<typename T>
is put on that line for inline ComponentID getComponentID() noexcept
. Why is that there? Obviously, there's no semicolon after a template declaration so I suppose it can be put on the same line but why? Is there something I'm missing? I haven't finished the video yet as this perplexed me and didn't wanna just go through the whole video copying code and not understanding it. Any hints?
Aucun commentaire:
Enregistrer un commentaire