0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

C++(91) Templates The Complete Guide(2nd Edition) (3)basics/referror2.cpp

Last updated at Posted at 2018-05-15

目的

このコンパイル記録は、コンパイラおよび対応標準、コンパイラの版により、コンパイルエラーMessageの違いを記録し、どのエラーが出たら、どの版またはどの対応標準にすればエラーが少なくなるかを考察するための資料です。

成果

コンパイラの種類、対応標準の違いによってエラーの数が違う。同じエラーであってもMessageの表現が違う。Error Messageのネットで検索する際に役立つ。

背景

C++のTemplate使いこなせてない。
The Complete Guide(2nd Edition)
http://www.tmplbook.com/code/code.html
コンパイルしながら勉強。

勉強の記録

https://researchmap.jp/joqzln3gi-1797580/#_1797580
だと, qiitaのようにコード表示機能がないためわかりにくい。
C++ Templates The Complete Guide(2nd Edition)をclang++とg++でコンパイルしてみた
https://qiita.com/kaizen_nagoya/items/a7065ea839cb33793bdf
コンパイルエラーになったものを
clang++, g++の -std=c++03, -std=c++2a
でコンパイルしながら一つづつ確認。

clang++

clang version 6.0.0 (tags/RELEASE_600/final)
Target: x86_64-apple-darwin17.5.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin

g++

g++ (Homebrew GCC 8.1.0) 8.1.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

basics/projectioniterator.cpp
#include <vector>
#include <iostream>

template<typename T, int& SZ>     // Note: size is reference
class Arr {
private:
  std::vector<T> elems;
public:
  Arr() : elems(SZ) {           // use current SZ as initial vector size
  }
  void print() const {
    for (int i=0; i<SZ; ++i) {  // loop over SZ elements
      std::cout << elems[i] << ' ';
    }
  }
};

int size = 10;

int main()
{
  Arr<int&,size> y; // compile-time ERROR deep in the code of class std::vector<>

  Arr<int,size> x;  // initializes internal vector with 10 elements
  x.print();        // OK
  size += 100;      // OOPS: modifies SZ in Arr<>
  x.print();        // run-time ERROR: invalid memory access: loops over 120 elements
}
cpla.sh
$ ../cpla.sh referror2
../cpla.sh: line 1: spla.sh: command not found
$ clang++ referror2.cpp -std=c++03 -Wall
In file included from referror2.cpp:1:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:266:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/__bit_reference:15:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/algorithm:643:
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:1770:16: error: 'pointer'
      declared as a pointer to a reference of type 'int &'
    typedef _Tp*              pointer;
               ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:1515:22: note: in
      instantiation of template class 'std::__1::allocator<int &>' requested
      here
    typedef typename allocator_type::value_type value_type;
                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:325:22: note: in
      instantiation of template class
      'std::__1::allocator_traits<std::__1::allocator<int &> >' requested here
    typedef typename __alloc_traits::size_type       size_type;
                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:448:15: note: in
      instantiation of template class 'std::__1::__vector_base<int &,
      std::__1::allocator<int &> >' requested here
    : private __vector_base<_Tp, _Allocator>
              ^
referror2.cpp:7:20: note: in instantiation of template class
      'std::__1::vector<int &, std::__1::allocator<int &> >' requested here
    std::vector<T> elems;
                   ^
referror2.cpp:22:18: note: in instantiation of template class
      'Arr<int &, &size>' requested here
  Arr<int&,size> y; // compile-time ERROR deep in the code of class std:...
                 ^
In file included from referror2.cpp:1:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:266:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/__bit_reference:15:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/algorithm:643:
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:1771:22: error: 
      'const_pointer' declared as a pointer to a reference of type 'int &'
    typedef const _Tp*        const_pointer;
                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:1785:45: error: multiple
      overloads of 'address' instantiate to the same signature
      'std::__1::allocator<int &>::const_pointer (std::__1::allocator<int
      &>::const_reference) const throw()' (aka 'int (int &) const throw()')
    _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x...
                                            ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:1783:39: note: previous
      declaration is here
    _LIBCPP_INLINE_VISIBILITY pointer address(reference __x) const _NOEXCEPT
                                      ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:950:22: error: implicit
      instantiation of undefined template
      'std::__1::__pointer_traits_element_type<int, false>'
    typedef typename __pointer_traits_element_type<pointer>::type    ele...
                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:1074:22: note: in
      instantiation of template class 'std::__1::pointer_traits<int>' requested
      here
    typedef typename pointer_traits<_Ptr>::template rebind<void>::other type;
                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:1519:22: note: in
      instantiation of template class 'std::__1::__void_pointer<int,
      std::__1::allocator<int &>, false>' requested here
    typedef typename __void_pointer<pointer, allocator_type>::type void_pointer;
                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:325:22: note: in
      instantiation of template class
      'std::__1::allocator_traits<std::__1::allocator<int &> >' requested here
    typedef typename __alloc_traits::size_type       size_type;
                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:448:15: note: in
      instantiation of template class 'std::__1::__vector_base<int &,
      std::__1::allocator<int &> >' requested here
    : private __vector_base<_Tp, _Allocator>
              ^
referror2.cpp:7:20: note: in instantiation of template class
      'std::__1::vector<int &, std::__1::allocator<int &> >' requested here
    std::vector<T> elems;
                   ^
referror2.cpp:22:18: note: in instantiation of template class
      'Arr<int &, &size>' requested here
  Arr<int&,size> y; // compile-time ERROR deep in the code of class std:...
                 ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:740:8: note: template is
      declared here
struct __pointer_traits_element_type;
       ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:1074:53: error: 'rebind'
      following the 'template' keyword does not refer to a template
    typedef typename pointer_traits<_Ptr>::template rebind<void>::other type;
                                                    ^~~~~~
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:1519:22: note: in
      instantiation of template class 'std::__1::__void_pointer<int,
      std::__1::allocator<int &>, false>' requested here
    typedef typename __void_pointer<pointer, allocator_type>::type void_pointer;
                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:325:22: note: in
      instantiation of template class
      'std::__1::allocator_traits<std::__1::allocator<int &> >' requested here
    typedef typename __alloc_traits::size_type       size_type;
                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:448:15: note: in
      instantiation of template class 'std::__1::__vector_base<int &,
      std::__1::allocator<int &> >' requested here
    : private __vector_base<_Tp, _Allocator>
              ^
referror2.cpp:7:20: note: in instantiation of template class
      'std::__1::vector<int &, std::__1::allocator<int &> >' requested here
    std::vector<T> elems;
                   ^
referror2.cpp:22:18: note: in instantiation of template class
      'Arr<int &, &size>' requested here
  Arr<int&,size> y; // compile-time ERROR deep in the code of class std:...
                 ^
In file included from referror2.cpp:1:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:266:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/__bit_reference:15:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/algorithm:643:
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:852:22: error: type 'int'
      cannot be used prior to '::' because it has no members
    typedef typename _Tp::template rebind<_Up>::other type;
                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:957:27: note: in
      instantiation of template class 'std::__1::__pointer_traits_rebind<int,
      const void, false>' requested here
        {typedef typename __pointer_traits_rebind<pointer, _Up>::type other;};
                          ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:1097:44: note: in
      instantiation of template class
      'std::__1::pointer_traits<int>::rebind<const void>' requested here
    typedef typename pointer_traits<_Ptr>::template rebind<const void>::...
                                           ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:1520:22: note: in
      instantiation of template class 'std::__1::__const_void_pointer<int,
      std::__1::allocator<int &>, false>' requested here
    typedef typename __const_void_pointer<pointer, allocator_type>::typ...
                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:325:22: note: in
      instantiation of template class
      'std::__1::allocator_traits<std::__1::allocator<int &> >' requested here
    typedef typename __alloc_traits::size_type       size_type;
                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:448:15: note: in
      instantiation of template class 'std::__1::__vector_base<int &,
      std::__1::allocator<int &> >' requested here
    : private __vector_base<_Tp, _Allocator>
              ^
referror2.cpp:7:20: note: in instantiation of template class
      'std::__1::vector<int &, std::__1::allocator<int &> >' requested here
    std::vector<T> elems;
                   ^
referror2.cpp:22:18: note: in instantiation of template class
      'Arr<int &, &size>' requested here
  Arr<int&,size> y; // compile-time ERROR deep in the code of class std:...
                 ^
In file included from referror2.cpp:1:
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:457:30: error: 
      '__alloc_traits' is a protected member of 'std::__1::__vector_base<int &,
      std::__1::allocator<int &> >'
    typedef typename __base::__alloc_traits          __alloc_traits;
                             ^
referror2.cpp:7:20: note: in instantiation of template class
      'std::__1::vector<int &, std::__1::allocator<int &> >' requested here
    std::vector<T> elems;
                   ^
referror2.cpp:22:18: note: in instantiation of template class
      'Arr<int &, &size>' requested here
  Arr<int&,size> y; // compile-time ERROR deep in the code of class std:...
                 ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:322:54: note: declared
      protected here
    typedef allocator_traits<allocator_type>         __alloc_traits;
                                                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:458:30: error: 'reference' is
      a protected member of 'std::__1::__vector_base<int &,
      std::__1::allocator<int &> >'
    typedef typename __base::reference               reference;
                             ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:323:54: note: declared
      protected here
    typedef value_type&                              reference;
                                                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:459:30: error: 
      'const_reference' is a protected member of 'std::__1::__vector_base<int &,
      std::__1::allocator<int &> >'
    typedef typename __base::const_reference         const_reference;
                             ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:324:54: note: declared
      protected here
    typedef const value_type&                        const_reference;
                                                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:460:30: error: 'size_type' is
      a protected member of 'std::__1::__vector_base<int &,
      std::__1::allocator<int &> >'
    typedef typename __base::size_type               size_type;
                             ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:325:54: note: declared
      protected here
    typedef typename __alloc_traits::size_type       size_type;
                                                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:461:30: error: 
      'difference_type' is a protected member of 'std::__1::__vector_base<int &,
      std::__1::allocator<int &> >'
    typedef typename __base::difference_type         difference_type;
                             ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:326:54: note: declared
      protected here
    typedef typename __alloc_traits::difference_type difference_type;
                                                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:462:30: error: 'pointer' is a
      protected member of 'std::__1::__vector_base<int &,
      std::__1::allocator<int &> >'
    typedef typename __base::pointer                 pointer;
                             ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:327:54: note: declared
      protected here
    typedef typename __alloc_traits::pointer         pointer;
                                                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:463:30: error: 
      'const_pointer' is a protected member of 'std::__1::__vector_base<int &,
      std::__1::allocator<int &> >'
    typedef typename __base::const_pointer           const_pointer;
                             ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:328:54: note: declared
      protected here
    typedef typename __alloc_traits::const_pointer   const_pointer;
                                                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:671:15: error: 'data'
      declared as a pointer to a reference of type 'std::__1::vector<int &,
      std::__1::allocator<int &> >::value_type' (aka 'int &')
    value_type*       data() _NOEXCEPT
              ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:674:21: error: 'data'
      declared as a pointer to a reference of type 'std::__1::vector<int &,
      std::__1::allocator<int &> >::value_type' (aka 'int &')
    const value_type* data() const _NOEXCEPT
                    ^
15 errors generated.
$ clang++ referror2.cpp -std=c++2a -Wall
In file included from referror2.cpp:1:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:266:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/__bit_reference:15:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/algorithm:643:
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:1770:16: error: 'pointer'
      declared as a pointer to a reference of type 'int &'
    typedef _Tp*              pointer;
               ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:1515:22: note: in
      instantiation of template class 'std::__1::allocator<int &>' requested
      here
    typedef typename allocator_type::value_type value_type;
                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:325:22: note: in
      instantiation of template class
      'std::__1::allocator_traits<std::__1::allocator<int &> >' requested here
    typedef typename __alloc_traits::size_type       size_type;
                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:448:15: note: in
      instantiation of template class 'std::__1::__vector_base<int &,
      std::__1::allocator<int &> >' requested here
    : private __vector_base<_Tp, _Allocator>
              ^
referror2.cpp:7:20: note: in instantiation of template class
      'std::__1::vector<int &, std::__1::allocator<int &> >' requested here
    std::vector<T> elems;
                   ^
referror2.cpp:22:18: note: in instantiation of template class
      'Arr<int &, &size>' requested here
  Arr<int&,size> y; // compile-time ERROR deep in the code of class std:...
                 ^
In file included from referror2.cpp:1:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:266:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/__bit_reference:15:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/algorithm:643:
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:1771:22: error: 
      'const_pointer' declared as a pointer to a reference of type 'int &'
    typedef const _Tp*        const_pointer;
                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:1785:45: error: multiple
      overloads of 'address' instantiate to the same signature
      'std::__1::allocator<int &>::const_pointer (std::__1::allocator<int
      &>::const_reference) const noexcept' (aka 'int (int &) const noexcept')
    _LIBCPP_INLINE_VISIBILITY const_pointer address(const_reference __x...
                                            ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:1783:39: note: previous
      declaration is here
    _LIBCPP_INLINE_VISIBILITY pointer address(reference __x) const _NOEXCEPT
                                      ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:950:22: error: implicit
      instantiation of undefined template
      'std::__1::__pointer_traits_element_type<int, false>'
    typedef typename __pointer_traits_element_type<pointer>::type    ele...
                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:1072:22: note: in
      instantiation of template class 'std::__1::pointer_traits<int>' requested
      here
    typedef typename pointer_traits<_Ptr>::template rebind<void> type;
                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:1519:22: note: in
      instantiation of template class 'std::__1::__void_pointer<int,
      std::__1::allocator<int &>, false>' requested here
    typedef typename __void_pointer<pointer, allocator_type>::type void_pointer;
                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:325:22: note: in
      instantiation of template class
      'std::__1::allocator_traits<std::__1::allocator<int &> >' requested here
    typedef typename __alloc_traits::size_type       size_type;
                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:448:15: note: in
      instantiation of template class 'std::__1::__vector_base<int &,
      std::__1::allocator<int &> >' requested here
    : private __vector_base<_Tp, _Allocator>
              ^
referror2.cpp:7:20: note: in instantiation of template class
      'std::__1::vector<int &, std::__1::allocator<int &> >' requested here
    std::vector<T> elems;
                   ^
referror2.cpp:22:18: note: in instantiation of template class
      'Arr<int &, &size>' requested here
  Arr<int&,size> y; // compile-time ERROR deep in the code of class std:...
                 ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:740:8: note: template is
      declared here
struct __pointer_traits_element_type;
       ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:1072:53: error: 'rebind'
      following the 'template' keyword does not refer to a template
    typedef typename pointer_traits<_Ptr>::template rebind<void> type;
                                                    ^~~~~~
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:1519:22: note: in
      instantiation of template class 'std::__1::__void_pointer<int,
      std::__1::allocator<int &>, false>' requested here
    typedef typename __void_pointer<pointer, allocator_type>::type void_pointer;
                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:325:22: note: in
      instantiation of template class
      'std::__1::allocator_traits<std::__1::allocator<int &> >' requested here
    typedef typename __alloc_traits::size_type       size_type;
                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:448:15: note: in
      instantiation of template class 'std::__1::__vector_base<int &,
      std::__1::allocator<int &> >' requested here
    : private __vector_base<_Tp, _Allocator>
              ^
referror2.cpp:7:20: note: in instantiation of template class
      'std::__1::vector<int &, std::__1::allocator<int &> >' requested here
    std::vector<T> elems;
                   ^
referror2.cpp:22:18: note: in instantiation of template class
      'Arr<int &, &size>' requested here
  Arr<int&,size> y; // compile-time ERROR deep in the code of class std:...
                 ^
In file included from referror2.cpp:1:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:266:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/__bit_reference:15:
In file included from /usr/local/Cellar/llvm/6.0.0/include/c++/v1/algorithm:643:
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:850:22: error: type 'int'
      cannot be used prior to '::' because it has no members
    typedef typename _Tp::template rebind<_Up> type;
                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:954:26: note: in
      instantiation of template class 'std::__1::__pointer_traits_rebind<int,
      const void, false>' requested here
    template <class _Up> using rebind = typename __pointer_traits_rebind...
                         ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:1095:53: note: in
      instantiation of template type alias 'rebind' requested here
    typedef typename pointer_traits<_Ptr>::template rebind<const void> type;
                                                    ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/memory:1520:22: note: in
      instantiation of template class 'std::__1::__const_void_pointer<int,
      std::__1::allocator<int &>, false>' requested here
    typedef typename __const_void_pointer<pointer, allocator_type>::typ...
                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:325:22: note: in
      instantiation of template class
      'std::__1::allocator_traits<std::__1::allocator<int &> >' requested here
    typedef typename __alloc_traits::size_type       size_type;
                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:448:15: note: in
      instantiation of template class 'std::__1::__vector_base<int &,
      std::__1::allocator<int &> >' requested here
    : private __vector_base<_Tp, _Allocator>
              ^
referror2.cpp:7:20: note: in instantiation of template class
      'std::__1::vector<int &, std::__1::allocator<int &> >' requested here
    std::vector<T> elems;
                   ^
referror2.cpp:22:18: note: in instantiation of template class
      'Arr<int &, &size>' requested here
  Arr<int&,size> y; // compile-time ERROR deep in the code of class std:...
                 ^
In file included from referror2.cpp:1:
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:457:30: error: 
      '__alloc_traits' is a protected member of 'std::__1::__vector_base<int &,
      std::__1::allocator<int &> >'
    typedef typename __base::__alloc_traits          __alloc_traits;
                             ^
referror2.cpp:7:20: note: in instantiation of template class
      'std::__1::vector<int &, std::__1::allocator<int &> >' requested here
    std::vector<T> elems;
                   ^
referror2.cpp:22:18: note: in instantiation of template class
      'Arr<int &, &size>' requested here
  Arr<int&,size> y; // compile-time ERROR deep in the code of class std:...
                 ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:322:54: note: declared
      protected here
    typedef allocator_traits<allocator_type>         __alloc_traits;
                                                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:458:30: error: 'reference' is
      a protected member of 'std::__1::__vector_base<int &,
      std::__1::allocator<int &> >'
    typedef typename __base::reference               reference;
                             ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:323:54: note: declared
      protected here
    typedef value_type&                              reference;
                                                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:459:30: error: 
      'const_reference' is a protected member of 'std::__1::__vector_base<int &,
      std::__1::allocator<int &> >'
    typedef typename __base::const_reference         const_reference;
                             ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:324:54: note: declared
      protected here
    typedef const value_type&                        const_reference;
                                                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:460:30: error: 'size_type' is
      a protected member of 'std::__1::__vector_base<int &,
      std::__1::allocator<int &> >'
    typedef typename __base::size_type               size_type;
                             ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:325:54: note: declared
      protected here
    typedef typename __alloc_traits::size_type       size_type;
                                                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:461:30: error: 
      'difference_type' is a protected member of 'std::__1::__vector_base<int &,
      std::__1::allocator<int &> >'
    typedef typename __base::difference_type         difference_type;
                             ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:326:54: note: declared
      protected here
    typedef typename __alloc_traits::difference_type difference_type;
                                                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:462:30: error: 'pointer' is a
      protected member of 'std::__1::__vector_base<int &,
      std::__1::allocator<int &> >'
    typedef typename __base::pointer                 pointer;
                             ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:327:54: note: declared
      protected here
    typedef typename __alloc_traits::pointer         pointer;
                                                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:463:30: error: 
      'const_pointer' is a protected member of 'std::__1::__vector_base<int &,
      std::__1::allocator<int &> >'
    typedef typename __base::const_pointer           const_pointer;
                             ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:328:54: note: declared
      protected here
    typedef typename __alloc_traits::const_pointer   const_pointer;
                                                     ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:671:15: error: 'data'
      declared as a pointer to a reference of type 'std::__1::vector<int &,
      std::__1::allocator<int &> >::value_type' (aka 'int &')
    value_type*       data() _NOEXCEPT
              ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:674:21: error: 'data'
      declared as a pointer to a reference of type 'std::__1::vector<int &,
      std::__1::allocator<int &> >::value_type' (aka 'int &')
    const value_type* data() const _NOEXCEPT
                    ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:691:36: error: multiple
      overloads of 'push_back' instantiate to the same signature 'void
      (std::__1::vector<int &, std::__1::allocator<int &> >::value_type &)'
    _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x);
                                   ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:688:36: note: previous
      declaration is here
    _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
                                   ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:708:14: error: multiple
      overloads of 'insert' instantiate to the same signature
      'std::__1::vector<int &, std::__1::allocator<int &> >::iterator
      (std::__1::vector<int &, std::__1::allocator<int &> >::const_iterator,
      std::__1::vector<int &, std::__1::allocator<int &> >::value_type &)' (aka
      '__wrap_iter<int> (__wrap_iter<int>, int &)')
    iterator insert(const_iterator __position, value_type&& __x);
             ^
/usr/local/Cellar/llvm/6.0.0/include/c++/v1/vector:705:14: note: previous
      declaration is here
    iterator insert(const_iterator __position, const_reference __x);
             ^
17 errors generated.
\r
$ g++-8 referror2.cpp -std=c++03  -Wall
In file included from /usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/x86_64-apple-darwin17.5.0/bits/c++allocator.h:33,
                 from /usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/allocator.h:46,
                 from /usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/vector:61,
                 from referror2.cpp:1:
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/ext/new_allocator.h: In instantiation of 'class __gnu_cxx::new_allocator<int&>':
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/allocator.h:108:11:   required from 'class std::allocator<int&>'
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:84:21:   required from 'struct std::_Vector_base<int&, std::allocator<int&> >'
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:339:11:   required from 'class std::vector<int&, std::allocator<int&> >'
referror2.cpp:7:20:   required from 'class Arr<int&, size>'
referror2.cpp:22:18:   required from here
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/ext/new_allocator.h:63:26: error:forming pointer to reference type 'int&'
       typedef _Tp*       pointer;
                          ^~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/ext/new_allocator.h:64:26: error:forming pointer to reference type 'int&'
       typedef const _Tp* const_pointer;
                          ^~~~~~~~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/ext/new_allocator.h:65:26: error:forming reference to reference type 'int&'
       typedef _Tp&       reference;
                          ^~~~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/ext/new_allocator.h:66:26: error:forming reference to reference type 'int&'
       typedef const _Tp& const_reference;
                          ^~~~~~~~~~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/ext/new_allocator.h:145:7: error:forming reference to reference type 'int&'
       construct(pointer __p, const _Tp& __val)
       ^~~~~~~~~
In file included from /usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/vector:61,
                 from referror2.cpp:1:
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/allocator.h: In instantiation of 'class std::allocator<int&>':
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:84:21:   required from 'struct std::_Vector_base<int&, std::allocator<int&> >'
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:339:11:   required from 'class std::vector<int&, std::allocator<int&> >'
referror2.cpp:7:20:   required from 'class Arr<int&, size>'
referror2.cpp:22:18:   required from here
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/allocator.h:113:26: error: forming pointer to reference type 'int&'
       typedef _Tp*       pointer;
                          ^~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/allocator.h:114:26: error: forming pointer to reference type 'int&'
       typedef const _Tp* const_pointer;
                          ^~~~~~~~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/allocator.h:115:26: error: forming reference to reference type 'int&'
       typedef _Tp&       reference;
                          ^~~~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/allocator.h:116:26: error: forming reference to reference type 'int&'
       typedef const _Tp& const_reference;
                          ^~~~~~~~~~~~~~~
In file included from /usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/vector:64,
                 from referror2.cpp:1:
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h: In instantiation of 'class std::vector<int&, std::allocator<int&> >':
referror2.cpp:7:20:   required from 'class Arr<int&, size>'
referror2.cpp:22:18:   required from here
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:379:20: error: no members matching 'std::vector<int&, std::allocator<int&> >::_Base {aka std::_Vector_base<int&, std::allocator<int&> >}::_M_allocate' in 'std::vector<int&, std::allocator<int&> >::_Base' {aka 'struct std::_Vector_base<int&, std::allocator<int&> >'}
       using _Base::_M_allocate;
                    ^~~~~~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:380:20: error: no members matching 'std::vector<int&, std::allocator<int&> >::_Base {aka std::_Vector_base<int&, std::allocator<int&> >}::_M_deallocate' in 'std::vector<int&, std::allocator<int&> >::_Base' {aka 'struct std::_Vector_base<int&, std::allocator<int&> >'}
       using _Base::_M_deallocate;
                    ^~~~~~~~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:441:7: error: forming reference to reference type 'std::vector<int&, std::allocator<int&> >::value_type' {aka 'int&'}
       vector(size_type __n, const value_type& __value = value_type(),
       ^~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:636:7: error: forming reference to reference type 'std::vector<int&, std::allocator<int&> >::value_type' {aka 'int&'}
       assign(size_type __n, const value_type& __val)
       ^~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:1055:7: error: forming pointer to reference type 'int&'
       data() _GLIBCXX_NOEXCEPT
       ^~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:1059:7: error: forming pointer to reference type 'int&'
       data() const _GLIBCXX_NOEXCEPT
       ^~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:1074:7: error: forming reference to reference type 'std::vector<int&, std::allocator<int&> >::value_type' {aka 'int&'}
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:1243:7: error: forming reference to reference type 'std::vector<int&, std::allocator<int&> >::value_type' {aka 'int&'}
       insert(iterator __position, size_type __n, const value_type& __x)
       ^~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:1472:7: error: forming reference to reference type 'std::vector<int&, std::allocator<int&> >::value_type' {aka 'int&'}
       _M_fill_initialize(size_type __n, const value_type& __value)
       ^~~~~~~~~~~~~~~~~~
In file included from /usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/vector:69,
                 from referror2.cpp:1:
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/vector.tcc:245:5: error: forming reference to reference type 'std::vector<int&, std::allocator<int&> >::value_type' {aka 'int&'}
     vector<_Tp, _Alloc>::
     ^~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/vector.tcc:478:5: error: forming reference to reference type 'std::vector<int&, std::allocator<int&> >::value_type' {aka 'int&'}
     vector<_Tp, _Alloc>::
     ^~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/vector.tcc:387:5: error: forming reference to reference type 'int&'
     vector<_Tp, _Alloc>::
     ^~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/vector.tcc:418:5: error: forming reference to reference type 'int&'
     vector<_Tp, _Alloc>::
     ^~~~~~~~~~~~~~~~~~~
In file included from /usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/vector:64,
                 from referror2.cpp:1:
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:1716:2: error: forming pointer to reference type 'std::vector<int&, std::allocator<int&> >::value_type' {aka 'int&'}
  _M_data_ptr(_Ptr __ptr)
  ^~~~~~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:1721:2: error: forming pointer to reference type 'std::vector<int&, std::allocator<int&> >::value_type' {aka 'int&'}
  _M_data_ptr(_Ptr __ptr) const
  ^~~~~~~~~~~
referror2.cpp: In instantiation of 'Arr<T, SZ>::Arr() [with T = int&; int& SZ = size]':
referror2.cpp:22:18:   required from here
referror2.cpp:9:21: error: no matching function for call to 'std::vector<int&, std::allocator<int&> >::vector(int&)'
     Arr() : elems(SZ) {           // use current SZ as initial vector size
                     ^
In file included from /usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/vector:64,
                 from referror2.cpp:1:
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:549:2: note: candidate: 'template<class _InputIterator> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&)'
  vector(_InputIterator __first, _InputIterator __last,
  ^~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:549:2: note:   template argument deduction/substitution failed:
referror2.cpp:9:21: note:   candidate expects 3 arguments, 1 provided
     Arr() : elems(SZ) {           // use current SZ as initial vector size
                     ^
In file included from /usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/vector:64,
                 from referror2.cpp:1:
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:458:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = int&; _Alloc = std::allocator<int&>]'
       vector(const vector& __x)
       ^~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:458:7: note:   no known conversion for argument 1 from 'int' to 'const std::vector<int&, std::allocator<int&> >&'
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:402:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = int&; _Alloc = std::allocator<int&>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int&>]'
       vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT
       ^~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:402:7: note:   no known conversion for argument 1 from 'int' to 'const allocator_type&' {aka 'const std::allocator<int&>&'}
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:391:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = int&; _Alloc = std::allocator<int&>]'
       vector()
       ^~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:391:7: note:   candidate expects 0 arguments, 1 provided
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h: In instantiation of 'std::vector<_Tp, _Alloc>::~vector() [with _Tp = int&; _Alloc = std::allocator<int&>]':
referror2.cpp:5:7:   required from here
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:567:30: error: struct std::_Vector_base<int&, std::allocator<int&> >::_Vector_impl' has no member named '_M_start'
  std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
                ~~~~~~~~~~~~~~^~~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:567:54: error: struct std::_Vector_base<int&, std::allocator<int&> >::_Vector_impl' has no member named '_M_finish'
  std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
                                        ~~~~~~~~~~~~~~^~~~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h: In instantiation of 'std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = int&; _Alloc = std::allocator<int&>]':
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:570:7:   required from 'std::vector<_Tp, _Alloc>::~vector() [with _Tp = int&; _Alloc = std::allocator<int&>]'
referror2.cpp:5:7:   required from here
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:285:24: error: struct std::_Vector_base<int&, std::allocator<int&> >::_Vector_impl' has no member named '_M_start'
  _M_deallocate(_M_impl._M_start,
                ~~~~~~~~^~~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:286:17: error: struct std::_Vector_base<int&, std::allocator<int&> >::_Vector_impl' has no member named '_M_end_of_storage'
         _M_impl._M_end_of_storage - _M_impl._M_start);
         ~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:286:45: error: struct std::_Vector_base<int&, std::allocator<int&> >::_Vector_impl' has no member named '_M_start'
         _M_impl._M_end_of_storage - _M_impl._M_start);
                                     ~~~~~~~~^~~~~~~~
\r
$ g++-8 referror2.cpp -std=c++2a  -Wall
In file included from /usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/x86_64-apple-darwin17.5.0/bits/c++allocator.h:33,
                 from /usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/allocator.h:46,
                 from /usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/vector:61,
                 from referror2.cpp:1:
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/ext/new_allocator.h: In instantiation of 'class __gnu_cxx::new_allocator<int&>':
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/allocator.h:108:11:   required from 'class std::allocator<int&>'
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:84:21:   required from 'struct std::_Vector_base<int&, std::allocator<int&> >'
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:339:11:   required from 'class std::vector<int&, std::allocator<int&> >'
referror2.cpp:7:20:   required from 'class Arr<int&, size>'
referror2.cpp:22:18:   required from here
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/ext/new_allocator.h:63:26: error:forming pointer to reference type 'int&'
       typedef _Tp*       pointer;
                          ^~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/ext/new_allocator.h:64:26: error:forming pointer to reference type 'int&'
       typedef const _Tp* const_pointer;
                          ^~~~~~~~~~~~~
In file included from /usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/vector:61,
                 from referror2.cpp:1:
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/allocator.h: In instantiation of 'class std::allocator<int&>':
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:84:21:   required from 'struct std::_Vector_base<int&, std::allocator<int&> >'
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:339:11:   required from 'class std::vector<int&, std::allocator<int&> >'
referror2.cpp:7:20:   required from 'class Arr<int&, size>'
referror2.cpp:22:18:   required from here
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/allocator.h:113:26: error: forming pointer to reference type 'int&'
       typedef _Tp*       pointer;
                          ^~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/allocator.h:114:26: error: forming pointer to reference type 'int&'
       typedef const _Tp* const_pointer;
                          ^~~~~~~~~~~~~
In file included from /usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/ext/alloc_traits.h:36,
                 from /usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_construct.h:61,
                 from /usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/vector:62,
                 from referror2.cpp:1:
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/alloc_traits.h: In instantiation of 'struct std::allocator_traits<std::allocator<int&> >':
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/ext/alloc_traits.h:50:10:   required from 'struct __gnu_cxx::__alloc_traits<std::allocator<int&>, int&>'
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:84:21:   required from 'struct std::_Vector_base<int&, std::allocator<int&> >'
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:339:11:   required from 'class std::vector<int&, std::allocator<int&> >'
referror2.cpp:7:20:   required from 'class Arr<int&, size>'
referror2.cpp:22:18:   required from here
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/alloc_traits.h:392:27: error: forming pointer to reference type 'int&'
       using pointer = _Tp*;
                           ^
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/alloc_traits.h:395:39: error: forming pointer to reference type 'int&'
       using const_pointer = const _Tp*;
                                       ^
In file included from /usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_construct.h:61,
                 from /usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/vector:62,
                 from referror2.cpp:1:
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/ext/alloc_traits.h: In instantiation of 'struct __gnu_cxx::__alloc_traits<std::allocator<int&>, int&>':
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:84:21:   required from 'struct std::_Vector_base<int&, std::allocator<int&> >'
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:339:11:   required from 'class std::vector<int&, std::allocator<int&> >'
referror2.cpp:7:20:   required from 'class Arr<int&, size>'
referror2.cpp:22:18:   required from here
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/ext/alloc_traits.h:66:23: error: no members matching '__gnu_cxx::__alloc_traits<std::allocator<int&>, int&>::_Base_type {aka std::allocator_traits<std::allocator<int&> >}::allocate' in '__gnu_cxx::__alloc_traits<std::allocator<int&>, int&>::_Base_type' {aka 'struct std::allocator_traits<std::allocator<int&> >'}
     using _Base_type::allocate;
                       ^~~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/ext/alloc_traits.h:67:23: error: no members matching '__gnu_cxx::__alloc_traits<std::allocator<int&>, int&>::_Base_type {aka std::allocator_traits<std::allocator<int&> >}::deallocate' in '__gnu_cxx::__alloc_traits<std::allocator<int&>, int&>::_Base_type' {aka 'struct std::allocator_traits<std::allocator<int&> >'}
     using _Base_type::deallocate;
                       ^~~~~~~~~~
In file included from /usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/vector:64,
                 from referror2.cpp:1:
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h: In instantiation of 'class std::vector<int&, std::allocator<int&> >':
referror2.cpp:7:20:   required from 'class Arr<int&, size>'
referror2.cpp:22:18:   required from here
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:379:20: error: no members matching 'std::vector<int&, std::allocator<int&> >::_Base {aka std::_Vector_base<int&, std::allocator<int&> >}::_M_allocate' in 'std::vector<int&, std::allocator<int&> >::_Base' {aka 'struct std::_Vector_base<int&, std::allocator<int&> >'}
       using _Base::_M_allocate;
                    ^~~~~~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:380:20: error: no members matching 'std::vector<int&, std::allocator<int&> >::_Base {aka std::_Vector_base<int&, std::allocator<int&> >}::_M_deallocate' in 'std::vector<int&, std::allocator<int&> >::_Base' {aka 'struct std::_Vector_base<int&, std::allocator<int&> >'}
       using _Base::_M_deallocate;
                    ^~~~~~~~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:1055:7: error: forming pointer to reference type 'int&'
       data() _GLIBCXX_NOEXCEPT
       ^~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:1059:7: error: forming pointer to reference type 'int&'
       data() const _GLIBCXX_NOEXCEPT
       ^~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:1090:7: error: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int&; _Alloc = std::allocator<int&>; std::vector<_Tp, _Alloc>::value_type = int&]' cannot be overloaded with 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int&; _Alloc = std::allocator<int&>; std::vector<_Tp, _Alloc>::value_type = int&]'
       push_back(value_type&& __x)
       ^~~~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:1074:7: note: previous declaration 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int&; _Alloc = std::allocator<int&>; std::vector<_Tp, _Alloc>::value_type = int&]'
       push_back(const value_type& __x)
       ^~~~~~~~~
In file included from /usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/utility:76,
                 from /usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_uninitialized.h:60,
                 from /usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/vector:63,
                 from referror2.cpp:1:
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/initializer_list: In instantiation of 'class std::initializer_list<int&>':
referror2.cpp:9:21:   required from 'Arr<T, SZ>::Arr() [with T = int&; int& SZ = size]'
referror2.cpp:22:18:   required from here
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/initializer_list:54:26: error: forming pointer to reference type 'int&'
       typedef const _E*  iterator;
                          ^~~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/initializer_list:55:26: error: forming pointer to reference type 'int&'
       typedef const _E*  const_iterator;
                          ^~~~~~~~~~~~~~
In file included from /usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/vector:64,
                 from referror2.cpp:1:
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h: In instantiation of 'std::vector<_Tp, _Alloc>::~vector() [with _Tp = int&; _Alloc = std::allocator<int&>]':
referror2.cpp:5:7:   required from here
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:567:30: error: struct std::_Vector_base<int&, std::allocator<int&> >::_Vector_impl' has no member named '_M_start'
  std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
                ~~~~~~~~~~~~~~^~~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:567:54: error: struct std::_Vector_base<int&, std::allocator<int&> >::_Vector_impl' has no member named '_M_finish'
  std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
                                        ~~~~~~~~~~~~~~^~~~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h: In instantiation of 'std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = int&; _Alloc = std::allocator<int&>]':
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:570:7:   required from 'std::vector<_Tp, _Alloc>::~vector() [with _Tp = int&; _Alloc = std::allocator<int&>]'
referror2.cpp:5:7:   required from here
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:285:24: error: struct std::_Vector_base<int&, std::allocator<int&> >::_Vector_impl' has no member named '_M_start'
  _M_deallocate(_M_impl._M_start,
                ~~~~~~~~^~~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:286:17: error: struct std::_Vector_base<int&, std::allocator<int&> >::_Vector_impl' has no member named '_M_end_of_storage'
         _M_impl._M_end_of_storage - _M_impl._M_start);
         ~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/local/Cellar/gcc/8.1.0/include/c++/8.1.0/bits/stl_vector.h:286:45: error: struct std::_Vector_base<int&, std::allocator<int&> >::_Vector_impl' has no member named '_M_start'
         _M_impl._M_end_of_storage - _M_impl._M_start);
                                     ~~~~~~~~^~~~~~~~

#まとめ

cpp clang++ g++
=-std=c++03 =-std=c++2a =-std=c++03 =-std=c++2a
referror2 15 17 30 20

##検討事項(agenda)
1)コンパイルエラーをなくす修正方法
clang++ -std=c++2aの方がエラーが多い。
2)役に立つまたは意味のあるその他の出力

#参考資料(reference)
docker gnu(gcc/g++) and llvm(clang/clang++)
https://qiita.com/drafts/059874ea39c4de64c0f7

[C][C++]の国際規格案の例題をコンパイルするときの課題7つ。
https://qiita.com/kaizen_nagoya/items/5f4b155030259497c4de

C++N4606 Working Draft 2016, ISO/IEC 14882, C++ standardのコード断片をコンパイルするためにしていること
https://qiita.com/kaizen_nagoya/items/a8d7ee2f2e29e76c19c1

コンパイル用shell script C版(clangとgcc)とC++版(clang++とg++)
https://qiita.com/kaizen_nagoya/items/74220c0577a512c2d7da

Clang/Clang++(LLVM) gcc/g++(GNU) コンパイラ警告等比較
https://qiita.com/kaizen_nagoya/items/9a82b958cc3aeef0403f

C++2003とC++2017でコンパイルエラーになるならない事例集
https://qiita.com/kaizen_nagoya/items/a13ea3823441c430edff

Qiitaに投稿するCのStyle例(暫定)
https://qiita.com/kaizen_nagoya/items/946df1528a6a1ef2bc0d

cpprefjpのdecltypeをコンパイル試験
https://qiita.com/kaizen_nagoya/items/090909af702f0d5d8a67

MISRA C++ 5-0-16
https://qiita.com/kaizen_nagoya/items/7df2d4e05db724752a74

C++ Templates Part1 BASICS Chapter 3. Class Templates 3.2 Use of Class Template Stack stack1test.cpp
https://qiita.com/kaizen_nagoya/items/cd5fc49106fad5a4e9ed

ISO/IEC TS 17961:2013 C Secure Coding Rules(1) All list(to be confirmed)
https://qiita.com/kaizen_nagoya/items/54e056195c4f11b850a1

C言語(C++)に対する誤解、曲解、無理解、爽快。
https://qiita.com/kaizen_nagoya/items/3f3992c9722c1cee2e3a

C Puzzle Bookの有り難み5つ、C言語規格及びCコンパイラの特性を認識
https://qiita.com/kaizen_nagoya/items/d89a48c1536a02ecdec9

'wchar.h' file not found で困った clang++ macOS
https://qiita.com/kaizen_nagoya/items/de15cd46d657517fac11

Open POSIX Test Suiteの使い方を調べはじめました
https://qiita.com/kaizen_nagoya/items/644d5e407f5faf96e6dc

MISRA-C 2012 Referenceに掲載している文献の入手可能性を確認
https://qiita.com/kaizen_nagoya/items/96dc8b125e462d5575bb

どうやって MISRA Example Suiteをコンパイルするか
https://qiita.com/kaizen_nagoya/items/fbdbff5ff696e2ca7f00

MISRA C まとめ #include
https://qiita.com/kaizen_nagoya/items/f1a79a7cbd281607c7c9

「C++完全理解ガイド」の同意できること上位10
https://qiita.com/kaizen_nagoya/items/aa5744e0c4a8618c7671

<この項は書きかけです。順次追記します。>
This article is not completed. I will add some words and/or centences in order.

自己記事一覧

Qiitaで逆リンクを表示しなくなったような気がする。時々、スマフォで表示するとあらわっることがあり、完全に削除したのではなさそう。

4月以降、せっせとリンクリストを作り、統計を取って確率を説明しようとしている。
2025年2月末を目標にしている。

一覧の一覧( The directory of directories of mine.) Qiita(100)
https://qiita.com/kaizen_nagoya/items/7eb0e006543886138f39

仮説(0)一覧(目標100現在40)
https://qiita.com/kaizen_nagoya/items/f000506fe1837b3590df

Qiita(0)Qiita関連記事一覧(自分)
https://qiita.com/kaizen_nagoya/items/58db5fbf036b28e9dfa6

Error一覧 error(0)
https://qiita.com/kaizen_nagoya/items/48b6cbc8d68eae2c42b8

C++ Support(0) 
https://qiita.com/kaizen_nagoya/items/8720d26f762369a80514

Coding(0) Rules, C, Secure, MISRA and so on
https://qiita.com/kaizen_nagoya/items/400725644a8a0e90fbb0

Ethernet 記事一覧 Ethernet(0)
https://qiita.com/kaizen_nagoya/items/88d35e99f74aefc98794

Wireshark 一覧 wireshark(0)、Ethernet(48)
https://qiita.com/kaizen_nagoya/items/fbed841f61875c4731d0

線網(Wi-Fi)空中線(antenna)(0) 記事一覧(118/300目標)
https://qiita.com/kaizen_nagoya/items/5e5464ac2b24bd4cd001

なぜdockerで機械学習するか 書籍・ソース一覧作成中 (目標100)
https://qiita.com/kaizen_nagoya/items/ddd12477544bf5ba85e2

プログラムちょい替え(0)一覧:4件
https://qiita.com/kaizen_nagoya/items/296d87ef4bfd516bc394

言語処理100本ノックをdockerで。python覚えるのに最適。:10+12
https://qiita.com/kaizen_nagoya/items/7e7eb7c543e0c18438c4

Python(0)記事をまとめたい。
https://qiita.com/kaizen_nagoya/items/088c57d70ab6904ebb53

安全(0)安全工学シンポジウムに向けて: 21
https://qiita.com/kaizen_nagoya/items/c5d78f3def8195cb2409

プログラマによる、プログラマのための、統計(0)と確率のプログラミングとその後
https://qiita.com/kaizen_nagoya/items/6e9897eb641268766909

転職(0)一覧
https://qiita.com/kaizen_nagoya/items/f77520d378d33451d6fe

物理記事 上位100
https://qiita.com/kaizen_nagoya/items/66e90fe31fbe3facc6ff

量子(0) 計算機, 量子力学
https://qiita.com/kaizen_nagoya/items/1cd954cb0eed92879fd4

数学関連記事100
https://qiita.com/kaizen_nagoya/items/d8dadb49a6397e854c6d

統計(0)一覧
https://qiita.com/kaizen_nagoya/items/80d3b221807e53e88aba

図(0) state, sequence and timing. UML and お絵描き
https://qiita.com/kaizen_nagoya/items/60440a882146aeee9e8f

品質一覧
https://qiita.com/kaizen_nagoya/items/2b99b8e9db6d94b2e971

言語・文学記事 100
https://qiita.com/kaizen_nagoya/items/42d58d5ef7fb53c407d6

医工連携関連記事一覧
https://qiita.com/kaizen_nagoya/items/6ab51c12ba51bc260a82

自動車 記事 100
https://qiita.com/kaizen_nagoya/items/f7f0b9ab36569ad409c5

通信記事100
https://qiita.com/kaizen_nagoya/items/1d67de5e1cd207b05ef7

日本語(0)一欄
https://qiita.com/kaizen_nagoya/items/7498dcfa3a9ba7fd1e68

英語(0) 一覧
https://qiita.com/kaizen_nagoya/items/680e3f5cbf9430486c7d

音楽 一覧(0)
https://qiita.com/kaizen_nagoya/items/b6e5f42bbfe3bbe40f5d

@kazuo_reve 新人の方によく展開している有益な情報」確認一覧
https://qiita.com/kaizen_nagoya/items/b9380888d1e5a042646b

鉄道(0)鉄道のシステム考察はてっちゃんがてつだってくれる
https://qiita.com/kaizen_nagoya/items/faa4ea03d91d901a618a

OSEK OS設計の基礎 OSEK(100)
https://qiita.com/kaizen_nagoya/items/7528a22a14242d2d58a3

coding (101) 一覧を作成し始めた。omake:最近のQiitaで表示しない5つの事象
https://qiita.com/kaizen_nagoya/items/20667f09f19598aedb68

官公庁・学校・公的団体(NPOを含む)システムの課題、官(0)
https://qiita.com/kaizen_nagoya/items/04ee6eaf7ec13d3af4c3

「はじめての」シリーズ  ベクタージャパン 
https://qiita.com/kaizen_nagoya/items/2e41634f6e21a3cf74eb

AUTOSAR(0)Qiita記事一覧, OSEK(75)
https://qiita.com/kaizen_nagoya/items/89c07961b59a8754c869

プログラマが知っていると良い「公序良俗」
https://qiita.com/kaizen_nagoya/items/9fe7c0dfac2fbd77a945

LaTeX(0) 一覧 
https://qiita.com/kaizen_nagoya/items/e3f7dafacab58c499792

自動制御、制御工学一覧(0)
https://qiita.com/kaizen_nagoya/items/7767a4e19a6ae1479e6b

Rust(0) 一覧 
https://qiita.com/kaizen_nagoya/items/5e8bb080ba6ca0281927

関連資料

' @kazuo_reve 私が効果を確認した「小川メソッド」
https://qiita.com/kazuo_reve/items/a3ea1d9171deeccc04da

' @kazuo_reve 新人の方によく展開している有益な情報
https://qiita.com/kazuo_reve/items/d1a3f0ee48e24bba38f1

' @kazuo_reve Vモデルについて勘違いしていたと思ったこと
https://qiita.com/kazuo_reve/items/46fddb094563bd9b2e1e

Engineering Festa 2024前に必読記事一覧

programの本質は計画だ。programは設計だ。
https://qiita.com/kaizen_nagoya/items/c8545a769c246a458c27

登壇直後版 色使い(JIS安全色) Qiita Engineer Festa 2023〜私しか得しないニッチな技術でLT〜 スライド編 0.15
https://qiita.com/kaizen_nagoya/items/f0d3070d839f4f735b2b

プログラマが知っていると良い「公序良俗」
https://qiita.com/kaizen_nagoya/items/9fe7c0dfac2fbd77a945

逆も真:社会人が最初に確かめるとよいこと。OSEK(69)、Ethernet(59)
https://qiita.com/kaizen_nagoya/items/39afe4a728a31b903ddc

統計の嘘。仮説(127)
https://qiita.com/kaizen_nagoya/items/63b48ecf258a3471c51b

自分の言葉だけで論理展開できるのが天才なら、文章の引用だけで論理展開できるのが秀才だ。仮説(136)
https://qiita.com/kaizen_nagoya/items/97cf07b9e24f860624dd

参考文献駆動執筆(references driven writing)・デンソークリエイト編
https://qiita.com/kaizen_nagoya/items/b27b3f58b8bf265a5cd1

「何を」よりも「誰を」。10年後のために今見習いたい人たち
https://qiita.com/kaizen_nagoya/items/8045978b16eb49d572b2

Qiitaの記事に3段階または5段階で到達するための方法
https://qiita.com/kaizen_nagoya/items/6e9298296852325adc5e

出力(output)と呼ばないで。これは状態(state)です。
https://qiita.com/kaizen_nagoya/items/80b8b5913b2748867840

coding (101) 一覧を作成し始めた。omake:最近のQiitaで表示しない5つの事象
https://qiita.com/kaizen_nagoya/items/20667f09f19598aedb68

あなたは「勘違いまとめ」から、勘違いだと言っていることが勘違いだといくつ見つけられますか。人間の間違い(human error(125))の種類と対策
https://qiita.com/kaizen_nagoya/items/ae391b77fffb098b8fb4

プログラマの「プログラムが書ける」思い込みは強みだ。3つの理由。仮説(168)統計と確率(17) , OSEK(79)
https://qiita.com/kaizen_nagoya/items/bc5dd86e414de402ec29

出力(output)と呼ばないで。これは状態(state)です。
https://qiita.com/kaizen_nagoya/items/80b8b5913b2748867840

これからの情報伝達手段の在り方について考えてみよう。炎上と便乗。
https://qiita.com/kaizen_nagoya/items/71a09077ac195214f0db

ISO/IEC JTC1 SC7 Software and System Engineering
https://qiita.com/kaizen_nagoya/items/48b43f0f6976a078d907

アクセシビリティの知見を発信しよう!(再び)
https://qiita.com/kaizen_nagoya/items/03457eb9ee74105ee618

統計論及確率論輪講(再び)
https://qiita.com/kaizen_nagoya/items/590874ccfca988e85ea3

読者の心をグッと惹き寄せる7つの魔法
https://qiita.com/kaizen_nagoya/items/b1b5e89bd5c0a211d862

@kazuo_reve 新人の方によく展開している有益な情報」確認一覧
https://qiita.com/kaizen_nagoya/items/b9380888d1e5a042646b

ソースコードで議論しよう。日本語で議論するの止めましょう(あるプログラミング技術の議論報告)
https://qiita.com/kaizen_nagoya/items/8b9811c80f3338c6c0b0

脳内コンパイラの3つの危険
https://qiita.com/kaizen_nagoya/items/7025cf2d7bd9f276e382

心理学の本を読むよりはコンパイラ書いた方がよくね。仮説(34)
https://qiita.com/kaizen_nagoya/items/fa715732cc148e48880e

NASAを超えるつもりがあれば読んでください。
https://qiita.com/kaizen_nagoya/items/e81669f9cb53109157f6

データサイエンティストの気づき!「勉強して仕事に役立てない人。大嫌い!!」『それ自分かも?』ってなった!!!
https://qiita.com/kaizen_nagoya/items/d85830d58d8dd7f71d07

「ぼくの好きな先生」「人がやらないことをやれ」プログラマになるまで。仮説(37) 
https://qiita.com/kaizen_nagoya/items/53e4bded9fe5f724b3c4

なぜ経済学徒を辞め、計算機屋になったか(経済学部入学前・入学後・卒業後対応) 転職(1)
https://qiita.com/kaizen_nagoya/items/06335a1d24c099733f64

プログラミング言語教育のXYZ。 仮説(52)
https://qiita.com/kaizen_nagoya/items/1950c5810fb5c0b07be4

【24卒向け】9ヶ月後に年収1000万円を目指す。二つの関門と三つの道。
https://qiita.com/kaizen_nagoya/items/fb5bff147193f726ad25

「【25卒向け】Qiita Career Meetup for STUDENT」予習の勧め
https://qiita.com/kaizen_nagoya/items/00eadb8a6e738cb6336f

大学入試不合格でも筆記試験のない大学に入って卒業できる。卒業しなくても博士になれる。
https://qiita.com/kaizen_nagoya/items/74adec99f396d64b5fd5

全世界の不登校の子供たち「博士論文」を書こう。世界子供博士論文遠隔実践中心 安全(99)
https://qiita.com/kaizen_nagoya/items/912d69032c012bcc84f2

小川メソッド 覚え(書きかけ)
https://qiita.com/kaizen_nagoya/items/3593d72eca551742df68

DoCAP(ドゥーキャップ)って何ですか?
https://qiita.com/kaizen_nagoya/items/47e0e6509ab792c43327

views 20,000越え自己記事一覧
https://qiita.com/kaizen_nagoya/items/58e8bd6450957cdecd81

Views1万越え、もうすぐ1万記事一覧 最近いいねをいただいた213記事
https://qiita.com/kaizen_nagoya/items/d2b805717a92459ce853

amazon 殿堂入りNo1レビュアになるまで。仮説(102)
https://qiita.com/kaizen_nagoya/items/83259d18921ce75a91f4

100以上いいねをいただいた記事16選
https://qiita.com/kaizen_nagoya/items/f8d958d9084ffbd15d2a

小川清最終講義、最終講義(再)計画, Ethernet(100) 英語(100) 安全(100)
https://qiita.com/kaizen_nagoya/items/e2df642e3951e35e6a53

<この記事は個人の過去の経験に基づく個人の感想です。現在所属する組織、業務とは関係がありません。>
This article is an individual impression based on my individual experience. It has nothing to do with the organization or business to which I currently belong.

文書履歴(document history)

ver. 0.10 初稿 20180515 コンパイルエラーが取れていない。

最後までおよみいただきありがとうございました。

いいね 💚、フォローをお願いします。

Thank you very much for reading to the last sentence.

Please press the like icon 💚 and follow me for your happy life.

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?