File tree Expand file tree Collapse file tree 1 file changed +16
-12
lines changed Expand file tree Collapse file tree 1 file changed +16
-12
lines changed Original file line number Diff line number Diff line change 3
3
4
4
#include < SDL.h>
5
5
6
+ /*
7
+ * Clean up each argument in the list
8
+ */
9
+ template <typename T, typename ... Args>
10
+ void cleanup (T *t, Args&&... args){
11
+ cleanup (t);
12
+ cleanup (std::forward<Args>(args)...);
13
+ }
6
14
/*
7
15
* These serve to free the passed argument and also provide the
8
16
* base cases for the template recursion
9
17
*/
10
- void cleanup (SDL_Window *win){
18
+ template <>
19
+ void cleanup<SDL_Window>(SDL_Window *win){
11
20
SDL_DestroyWindow (win);
12
21
}
13
- void cleanup (SDL_Renderer *ren){
22
+ template <>
23
+ void cleanup<SDL_Renderer>(SDL_Renderer *ren){
14
24
SDL_DestroyRenderer (ren);
15
25
}
16
- void cleanup (SDL_Texture *tex){
26
+ template <>
27
+ void cleanup<SDL_Texture>(SDL_Texture *tex){
17
28
SDL_DestroyTexture (tex);
18
29
}
19
- void cleanup (SDL_Surface *surf){
30
+ template <>
31
+ void cleanup<SDL_Surface>(SDL_Surface *surf){
20
32
SDL_FreeSurface (surf);
21
33
}
22
- /*
23
- * Clean up each argument in the list
24
- */
25
- template <typename T, typename ... Args>
26
- void cleanup (T *t, Args&&... args){
27
- cleanup (t);
28
- cleanup (std::forward<Args>(args)...);
29
- }
30
34
31
35
#endif
32
36
You can’t perform that action at this time.
0 commit comments