fork(2) download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. template<bool IsVector = true>
  6. struct Bar {
  7. template<typename In>
  8. static auto foo(In input) {
  9. return input[0];
  10. }
  11. };
  12. template<>
  13. struct Bar<false> {
  14. template<typename In>
  15. static auto foo(In input) {
  16. return input;
  17. }
  18. };
  19.  
  20. int main() {
  21. cout << Bar<true>::foo(std::vector<double>{{1, 2 , 3}}) << endl;
  22. cout << Bar<false>::foo(4.5) << endl;
  23. return 0;
  24. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
1
4.5