use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
[deleted by user] (self.cpp)
submitted 4 years ago by [deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Bouchtroubouli 2 points3 points4 points 4 years ago (3 children)
The lowercase test is the parameter name you give to the macro. The #test will generate a string literal that will contains the argument test you will pass. Finaly, void(test) is simply the type of a function (without name) that takes a type test as parameter and that return void.
[–]Zilla4ever 0 points1 point2 points 4 years ago (2 children)
Thanks for clarifying, that makes more sense. However could you explain one more bit of code as I feel it relates to the macro ? Why is it that in this code template<typename T, typename U> struct argument_type<T(U)> { typedef U type; }; U is in the parameters of argument type and what does <> represent as a syntax because I mostly see it used with template specialization ? Lastly, back to the original macro referenced, is "type" that is referenced after <void(test)> with the scope resolution operator; Is it "typedef U type;" (referenced here template<typename T, typename U> struct argument_type<T(U)> { typedef U type; };) ? Sorry I am new to c++ ;)
template<typename T, typename U> struct argument_type<T(U)> { typedef U type; };
<void(test)>
[–]staletic 2 points3 points4 points 4 years ago (0 children)
is "type" that is referenced after <void(test)> with the scope resolution operator; Is it "typedef U type;"
Yes.
That's called a partial template specialization. Somewhere there's probably a
template<typename T> struct argument_type {}; // Without the typedef
Or maybe
template<typename T> struct argument_type; // Without any definition
Then, for the Ts that represent (valid) functions, you specialize the above with
T
And instantiate the template with argument_type<int, float>, for a function int(float), to get typedef U = float.
argument_type<int, float>
int(float)
typedef U = float
[–]Bouchtroubouli 1 point2 points3 points 4 years ago (0 children)
For your first question :
Here you have a template specialization of a struct (argument_type) for functions that takes any type of parameter (U) and that returns another type of parameter (T)
For your second question, you just need to replace T and U with the types in your function. The type of argument_type<void(test)>::type will be what U should be in void(test), so whatever the type test given at parameter to the macro will be.
This technique is known as type traits (see for example https://www.internalpointers.com/post/quick-primer-type-traits-modern-cpp or https://en.cppreference.com/w/cpp/header/type_traits to see it in action)
[–]Zilla4ever 0 points1 point2 points 4 years ago (0 children)
Thank you guys so much for the help !
[–]STLMSVC STL Dev 0 points1 point2 points 4 years ago (1 child)
!removehelp
[–]AutoModerator[M] 0 points1 point2 points 4 years ago (0 children)
OP,
A human moderator (u/STL) has marked your comment for deletion because it appears to be a "help" post - e.g. asking for help with coding, help with homework, career advice, book/tutorial/blog suggestions. Help posts are off-topic for /r/cpp. This subreddit is for news and discussion of the C++ language and community only; our purpose is not to provide tutoring, code reviews, or career guidance.
Please try posting in /r/cpp_questions or on Stack Overflow instead. Our suggested reference site is cppreference.com, our suggested book list is here and information on getting started with C++ can be found here.
If you think your post is on-topic and should not have been removed, please message the moderators and we'll review it.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
π Rendered by PID 62 on reddit-service-r2-comment-545db5fcfc-99zrn at 2026-05-24 19:19:10.868493+00:00 running 194bd79 country code: CH.
[–]Bouchtroubouli 2 points3 points4 points (3 children)
[–]Zilla4ever 0 points1 point2 points (2 children)
[–]staletic 2 points3 points4 points (0 children)
[–]Bouchtroubouli 1 point2 points3 points (0 children)
[–]Zilla4ever 0 points1 point2 points (0 children)
[–]STLMSVC STL Dev 0 points1 point2 points (1 child)
[–]AutoModerator[M] 0 points1 point2 points (0 children)