online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <iostream> // std::cout #include <type_traits> // std::is_same #include <vector> #include <typeinfo> // typeid #include <cxxabi.h> // abi template<typename Container, typename Index> // works, but auto authAndAccess(Container& c, Index i) // requires -> decltype(c[i]) // refinement { return c[i]; } template<typename Container, typename Index> auto authAndAccess14(Container& c, Index i) { return c[i]; } template<typename Container, typename Index> decltype(auto) authAndAccess14_2(Container& c, Index i) { return c[i]; } template<typename Container, typename Index> decltype(auto) authAndAccess14_2_const(const Container& c, Index i) { return c[i]; } template<typename Container, typename Index> // final decltype(auto) // C++14 authAndAccess14_perfect(Container&& c, Index i) // version { return std::forward<Container>(c)[i]; } template<class T1, class T2> void print_is_same() { std::cout << std::boolalpha << std::is_same<T1, T2>() << '\n'; } int main() { std::vector<float> vec {1.,2.,3.,5.}; typedef decltype(authAndAccess(vec, 2.)) ReturnType; typedef decltype(authAndAccess14(vec, 2.)) ReturnType14; typedef decltype(authAndAccess14_2(vec, 2.)) ReturnType14_2; typedef decltype(authAndAccess14_perfect(std::vector<float> {1.,2.,3.,5.}, 2.)) ReturnType14_perfect; typedef decltype(authAndAccess14_2_const(std::vector<float> {1.,2.,3.,5.}, 2.)) ReturnType14_2_const; print_is_same<float, std::remove_reference<ReturnType>::type>(); print_is_same<float, ReturnType>(); print_is_same<float, std::remove_reference<ReturnType14>::type>(); print_is_same<float, ReturnType14>(); print_is_same<float, std::remove_reference<ReturnType14_2>::type>(); print_is_same<float, ReturnType14_2>(); print_is_same<float, std::remove_reference<ReturnType14_perfect>::type>(); print_is_same<float, ReturnType14_perfect>(); int status; char *realname = abi::__cxa_demangle(typeid(ReturnType14_2_const).name(), 0, 0, &status); std::cout << realname << "\n"; print_is_same<float, std::remove_reference<ReturnType14_2_const>::type>(); print_is_same<float, std::remove_const< std::remove_reference<ReturnType14_2_const>::type >::type>(); print_is_same<float, std::remove_reference< std::remove_const<ReturnType14_2_const>::type >::type>(); print_is_same<float, ReturnType14_2_const>(); }

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