Skip to content

Template on static functions #8505

Answered by orklah
gruni1992 asked this question in Q&A
Sep 22, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

The basic principle is that class level templates are used to describe the state of a specific instance of a class (For example, you can have a Collection<Cat> in some variable and a Collection<Dog> in another.) You get to that state by pushing an array of Dogs in a Collection and an other array of Cats in another.

By that definition, it makes little sense to have a static method using a class level template because the method doesn't belong to a specific instance so the template could not have been initialized.

However, we know that this definition is restrictive and for cases like yours (where the class level template is not designed to describe the content of a specific instance but ra…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@AndrolGenhald
Comment options

Answer selected by gruni1992
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants