fork download
  1. #include <type_traits>
  2.  
  3. template <typename T, typename ...Ts>
  4. struct is_first_arg_const_ptr
  5. {
  6. template <typename Ret>
  7. static std::false_type
  8. is_const(Ret (&f)(T*, Ts...));
  9.  
  10. template <typename Ret>
  11. static std::true_type
  12. is_const(Ret (&f)(const T*, Ts...));
  13. };
  14.  
  15. class C {};
  16.  
  17. void fun2(C*) {}
  18. void fun2(const C*, int) {}
  19.  
  20. static_assert(!decltype(is_first_arg_const_ptr<C>::is_const(fun2))::value, "");
  21. static_assert(decltype(is_first_arg_const_ptr<C, int>::is_const(fun2))::value, "");
  22.  
  23. int main ()
  24. {
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0s 3336KB
stdin
Standard input is empty
stdout
Standard output is empty