Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
(non?)-template template parameters for container stream insertion
// Can https://stackoverflow.com/a/14311714 be reasonably rewritten with only // non-template template parameters? (Try 1: overload resolution is a problem.) #include <iostream> #include <vector> #include <deque> #include <list> #define USE_TEMPLATE_TEMPLATE_PARAMETER_VERSION false #if USE_TEMPLATE_TEMPLATE_PARAMETER_VERSION template<typename T, template<class,class...> class C, class... Args> std::ostream& operator <<(std::ostream& os, const C<T,Args...>& objs) { os << __PRETTY_FUNCTION__ << '\n'; for (auto const& obj : objs) os << obj << ' '; return os; } #else template<typename Container> std::ostream& operator <<(std::ostream& os, const Container& objs) { os << __PRETTY_FUNCTION__ << '\n'; for (auto const& obj : objs) os << obj << ' '; return os; } #endif int main() { std::vector<float> vf { 1.1, 2.2, 3.3, 4.4 }; std::cout << vf << '\n'; std::list<char> lc { 'a', 'b', 'c', 'd' }; std::cout << lc << '\n'; std::deque<int> di { 1, 2, 3, 4 }; std::cout << di << '\n'; return 0; }
run
|
edit
|
history
|
help
0
Composite pattern
Segment Tree Impl
Uno
wasm test for node
back_inserter example
non-template template parameters for container stream insertion: SFINAE
Pure virtual function called!
Error
BinaryGap, C++ - Find longest sequence of zeros in binary representation of an integer.
Recursive Call Example Sum