Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Sep 15th, 2013  |  syntax: None  |  size: 3.93 KB  |  views: 30  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ┌─(~/Src/C++/main)────────────────────────────────────────────────(soon@archlinux:pts/7)─┐
  2. └─(23:17:44)──> cat main.cpp                                               ──(Sun,Sep15)─┘
  3. #include <vector>
  4. #include <utility>
  5.  
  6. typedef float float2[2];
  7.  
  8. std::pair<float2,unsigned int>
  9.   make_pair(const float2 &first,unsigned int second)
  10. {
  11.   std::pair<float2,unsigned int> result;
  12.   result.first[0] = first[0];
  13.   result.first[1] = first[1];
  14.   result.second = second;
  15.   return result;
  16. }
  17.  
  18. int main(int,char**)
  19. {
  20.   unsigned int j = 0;
  21.   float2 ab = {1.0, 2.0};
  22.   std::vector<std::pair<float2, unsigned int> > myVec;
  23.   myVec.push_back(make_pair(ab, j));
  24.   return 0;
  25. }
  26. ┌─(~/Src/C++/main)────────────────────────────────────────────────(soon@archlinux:pts/7)─┐
  27. └─(09:28:17)──> clang++ main.cpp -std=c++11                                ──(Mon,Sep16)─┘
  28. ┌─(~/Src/C++/main)────────────────────────────────────────────────(soon@archlinux:pts/7)─┐
  29. └─(09:28:39)──> clang++ main.cpp -std=c++11 -stdlib=libc++                 ──(Mon,Sep16)─┘
  30. In file included from main.cpp:1:
  31. In file included from /usr/include/c++/v1/vector:261:
  32. In file included from /usr/include/c++/v1/__bit_reference:15:
  33. In file included from /usr/include/c++/v1/algorithm:593:
  34. /usr/include/c++/v1/utility:283:11: error: array initializer must be an initializer list
  35.         : first(_VSTD::forward<first_type>(__p.first)),
  36.           ^
  37. main.cpp:13:10: note: in instantiation of member function 'std::__1::pair<float [2],
  38.       unsigned int>::pair' requested here
  39.   return result;
  40.          ^
  41. In file included from main.cpp:1:
  42. In file included from /usr/include/c++/v1/vector:261:
  43. In file included from /usr/include/c++/v1/__bit_reference:15:
  44. In file included from /usr/include/c++/v1/algorithm:593:
  45. /usr/include/c++/v1/utility:246:11: error: array initializer must be an initializer list
  46.         : first(__p.first),
  47.           ^
  48. /usr/include/c++/v1/memory:1685:31: note: in instantiation of member function
  49.       'std::__1::pair<float [2], unsigned int>::pair' requested here
  50.             ::new((void*)__p) _Up(_VSTD::forward<_Args>(__args)...);
  51.                               ^
  52. /usr/include/c++/v1/memory:1612:18: note: in instantiation of function template
  53.       specialization 'std::__1::allocator<std::__1::pair<float [2], unsigned int>
  54.       >::construct<std::__1::pair<float [2], unsigned int>, std::__1::pair<float [2],
  55.       unsigned int> >' requested here
  56.             {__a.construct(__p, _VSTD::forward<_Args>(__args)...);}
  57.                  ^
  58. /usr/include/c++/v1/memory:1493:14: note: in instantiation of function template
  59.       specialization 'std::__1::allocator_traits<std::__1::allocator<std::__1::pair<float
  60.       [2], unsigned int> > >::__construct<std::__1::pair<float [2], unsigned int>,
  61.       std::__1::pair<float [2], unsigned int> >' requested here
  62.             {__construct(__has_construct<allocator_type, pointer, _Args...>(),
  63.              ^
  64. /usr/include/c++/v1/vector:1535:25: note: in instantiation of function template
  65.       specialization 'std::__1::allocator_traits<std::__1::allocator<std::__1::pair<float
  66.       [2], unsigned int> > >::construct<std::__1::pair<float [2], unsigned int>,
  67.       std::__1::pair<float [2], unsigned int> >' requested here
  68.         __alloc_traits::construct(this->__alloc(),
  69.                         ^
  70. main.cpp:21:9: note: in instantiation of member function
  71.       'std::__1::vector<std::__1::pair<float [2], unsigned int>,
  72.       std::__1::allocator<std::__1::pair<float [2], unsigned int> > >::push_back' requested
  73.       here
  74.   myVec.push_back(make_pair(ab, j));
  75.         ^
  76. 2 errors generated.
clone this paste RAW Paste Data