online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include<string> struct Name { std::string name ; std::string GetString() const { std::cout<<"GetString Called"<<std::endl; return name; } }; struct Person { }; void SetString(std::string n) { std::cout<<"SetString Called"<<std::endl; } //this function template will work if the class type has a member function named GetString template <typename T> auto Function (T const & x) -> decltype( x.GetString(), void()) { SetString(x.GetString()); }; int main() { Name n; Function(n); //works because Name has member function GetString Person p; //Function(p); //wont work because Person has no member function named GetString return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue