Run Code  | API  | Code Wall  | Misc  | Feedback  | Login  | Theme  | Privacy  | Patreon 

Trigger static_assert even when function signature is invalid

Language: Layout:
+ ] Compiler args + ] Show input
Compilation time: 0.12 sec, absolute service time: 0,21 sec 
edit mode |  history
Error(s):
source_file.cpp:17:3: error: static_assert failed "the template parameter to f should be `foo` or `bar`"
  static_assert(std::is_base_of<compatible_with_f, T>::value,
  ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
source_file.cpp:33:3: note: in instantiation of function template specialization 'f<int>' requested here
  f<int>(0); // error: no matching function for call to 'f'
  ^
1 error generated.

        

    
                
λ
.NET NoSQL database for rapid development