online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <array> #include <vector> #include <deque> #include <utility> #include <cstddef> #include <iostream> #include <algorithm> template <typename T> struct is_array_or_vector { enum { value = false }; }; template <typename T> struct is_array_or_vector<std::vector<T>> { enum { value = true }; }; template <typename T, std::size_t N> struct is_array_or_vector<std::array<T, N>> { enum { value = true }; }; #if 0 template <template<typename> typename T, typename T2, typename... Args> typename std::enable_if<is_array_or_vector<T<T2, Args...>>::value>::type f( const T<T2, Args...>& arr, T2 o) { auto it = std::find(arr.begin(), arr.end(), o); if ( it != arr.end() ) { std::cout << "found\n"; } else { std::cout << "not found\n"; } } #else template <typename T, typename T2> typename std::enable_if<is_array_or_vector<T>::value>::type f( const T& arr, T2 o) { auto it = std::find(arr.begin(), arr.end(), o); if ( it != arr.end() ) { std::cout << "found\n"; } else { std::cout << "not found\n"; } } #endif int main() { std::vector vec = {0, 1, 2, 3, 4}; std::array arr = {0u, 5u}; f(vec, 1); f(arr, 5); }

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