Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
enable_if::type
//Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x86 #include <iostream> #include <type_traits> template<int N> typename std::enable_if< (N>1) && (N<10), double>::type fix(double(&a)[N]) { double ml = a[0]; for(int i = 1; i < N; i++) ml *= a[i]; return ml; } template<int N> typename std::enable_if< (N>=10) || (N <=1), double>::type fix(double(&a)[N]) { return 0; } int main() { double a[] = {1,2.f, 4.5,6}; double b[] = {1, 2, 3, 4, 4, 5, 7, 0.1, 11, 12, 12,334, 45, 6}; std::cout << fix(a) << std::endl; std::cout << fix(b) << std::endl; }
run
|
edit
|
history
|
help
0
javascritp
Template function declaration to avoid usage of template in T::template f<int>()
Is a Union Member's Destructor Called
#9
fun
vector destruction - visual studio
#21
Arrays
cv3
typeid VC++