online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <future> #include <iostream> #include <tuple> template <class X, class Tuple> class Idx; template <class X, class... T> class Idx<X, std::tuple<T...>> { template <std::size_t... idx> static constexpr ssize_t find_idx(std::index_sequence<idx...>) { return -1 + ((std::is_same<X, T>::value ? idx + 1 : 0) + ...); } public: static constexpr ssize_t value = find_idx(std::index_sequence_for<T...>{}); }; int main() { using T = std::tuple<int, char, std::future<void>>; std::cout << Idx<std::promise<void>, T>::value << '\n' << Idx<int, T>::value << '\n' << Idx<char, T>::value << '\n' << Idx<std::future<void>, T>::value << std::endl; //constexpr auto idx = Idx<unsigned, T>::value; //static_assert(idx == -1, "Type not found"); }

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