Guest User

Untitled

a guest
Nov 25th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. template<>
  2. inline const char* begin(const char*& _Cont) noexcept
  3. {
  4. return _Cont;
  5. }
  6.  
  7. inline const char* begin(const char*& Cont)
  8. {
  9. return Cont;
  10. }
  11.  
  12. #include <iostream>
  13.  
  14. const char* begin(const char* str) noexcept
  15. {
  16. return str;
  17. }
  18.  
  19. const char* end(const char* str) noexcept
  20. {
  21. int count = strlen(str);
  22. return str + count;
  23. }
  24.  
  25. int main()
  26. {
  27. for(auto c : "Hello Moscow!")
  28. std::cout << c;
  29. std::cout << "n";
  30. }
  31.  
  32. #include <iostream>
  33.  
  34. namespace std
  35. {
  36. const char* begin(const char* str) noexcept
  37. {
  38. return str;
  39. }
  40.  
  41. const char* end(const char* str) noexcept
  42. {
  43. int count = strlen(str);
  44. return str + count;
  45. }
  46. }
  47.  
  48.  
  49. int main()
  50. {
  51. const char* str = "Hello Moscow!";
  52. for(auto c: str)
  53. std::cout << c;
  54. std::cout << "n";
  55. }
  56.  
  57. template<class _Container>
  58. auto inline begin(_Container& _Cont) -> decltype(_Cont.begin())
  59.  
  60. template<class _Container>
  61. auto inline begin(const _Container& _Cont) -> decltype(_Cont.begin())
  62.  
  63. template<class _Ty, size_t _Size>
  64. inline_CONST_FUN _Ty *begin(_Ty (&_Array)[_Size]) _NOEXCEPT
  65.  
  66. template<>
  67. inline const char* begin(const char*& _Cont) noexcept
  68.  
  69. #include <iostream>
  70. #include <iterator>
  71. #include <vector>
  72.  
  73. namespace std
  74. {
  75. template<>
  76. int *begin(int(&_Array)[50]) noexcept
  77. {
  78. std::cout << "Yeah!n";
  79. return nullptr;
  80. }
  81.  
  82. template<>
  83. auto inline begin(const std::vector<int>& _Cont) -> decltype(_Cont.begin())
  84. {
  85. std::cout << "Beah!n";
  86. return _Cont.begin();
  87. }
  88. }
  89.  
  90.  
  91. int main()
  92. {
  93. int a[50];
  94. std::begin(a);
  95. std::begin(std::vector<int>{});
  96. }
Add Comment
Please, Sign In to add comment