Home>
I am trying to determine if a function with default arguments can be called in requirements, but the default arguments do not seem to be taken into account.
I understand that the type is void (* fp) (int, int), so when I write like the following code, it becomes false.
So I don't know how to write the default argument. Does it exist in the first place?
# include<type_traits>
#include<iostream>
template<typename T>
concept C = requires (T x)
{
x (10);
};
void f (int, int = 1) {}
int main ()
{
std :: cout<<std :: boolalpha<<C<decltype (f)><<std :: endl;// false is output
return 0;
}
-
Answer # 1
Related articles
- about the structure of functions in c ++ code
- [c ++] about inherited class functions [rust]
- c ++ - about creating overloaded functions with different return values
- about c ++ bubble sort
- about passing ruby arguments (arrays)
- c ++ - confirmation about constexpr
- about php functions
- java - about the two arguments of onclick
- about the associative law of c ++ 20 templates
- c ++ - about the return value of the constructor
- c ++ - questions about passing by value and passing by reference
- c ++ - about getting the number of elements in a two-dimensional array
- c ++: about stack overflow
- about embedding random numbers in c ++ output file names
- c ++ - template functions with nested template classes
- vuejs - about vue's dynamic arguments
- about the meaning of c ++ (struct-like) code
- c ++ - about test case output
- how to pass command line arguments to a c ++ executable with a shell script
- about measuring the average processing time during continuous execution in c ++
Trends
There is no default argument information in the type information, so no matter how the type is manipulated, it is not possible to make a judgment considering the default argument.
A function with a default argument is lost as an argument to another function or as a template argument at that point.
So if the concept takes into account the default arguments, it will probably not fit.
It seems to be a deliberate design that default arguments are not considered in theconcept.