From: schwarzb@dqel.com   
      
   The problem appears to be that vector does not have a constructor that   
   accepts a const type.   
      
   Can you change it to   
    const std::vector ...   
   or will you be adding more elements to the vector later?   
      
   On Wed, 4 Dec 2013 07:07:04 CST, Helmut Jarausch   
    wrote:   
      
   >   
   >Hi,   
   >   
   >I cannot initialize a vector of const string elements with gcc-4.8.2   
   -std=c++11   
   >The example below will be compiled if 'const string' is replaced by   
   'string'.   
   >   
   >Is this a gcc bug or a restriction of the C++11 standard?   
   >   
   >Many thanks for a hint,   
   >Helmut   
   >   
   >#include    
   >using std::string;   
   >   
   >#include    
   >   
   >int main() { // compiled with std=c++11 using gcc-4.8.2   
   >   
   > std::vector Labels= {"A","B"};   
   >}   
   >   
   >   
   >/* I have removed '/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.2/include'   
   > at the beginning of the error messages below   
   >In file included   
   >from x86_64-pc-linux-gnu/bits/c++allocator.h:33:0,   
   >from bits/allocator.h:46,   
   >from string:41,   
   >from Vector_init_const_string.C:1:   
   >ext/new_allocator.h: In instantiation of   
   > 'struct __gnu_cxx::new_allocator >':   
   >...   
   >Vector_init_const_string.C:8:29:   
   > required from here   
   >ext/new_allocator.h:93:7: error:   
   > 'const _Tp* __gnu_cxx::new_allocator<_Tp>::   
   > address(__gnu_cxx::new_allocator<_Tp>::const_reference) const   
   > [with _Tp = const std::basic_string;   
   > __gnu_cxx::new_allocator<_Tp>::const_pointer   
   > = const std::basic_string*;   
   __gnu_cxx::new_allocator<_Tp>::const_reference   
   > = const std::basic_string&]' cannot be overloaded   
   > address(const_reference __x) const _GLIBCXX_NOEXCEPT   
   >   
   >ext/new_allocator.h:89:7: error:   
   > with '_Tp*   
   __gnu_cxx::new_allocator<_Tp>::address(__gnu_cxx::new_allocator<_Tp>::refere   
   nce)   
   > const [with _Tp = const std::basic_string;   
   __gnu_cxx::new_allocator<_Tp>::pointer   
   > = const std::basic_string*;   
   __gnu_cxx::new_allocator<_Tp>::reference = const std::basic_string&]'   
   > address(reference __x) const _GLIBCXX_NOEXCEPT   
   >   
   >ext/new_allocator.h: In instantiation of   
   > 'void   
   __gnu_cxx::new_allocator<_Tp>::deallocate(__gnu_cxx::new_allocator<_Tp>::poi   
   nter,   
   > __gnu_cxx::new_allocator<_Tp>::size_type)   
   > [with _Tp = const std::basic_string;   
   > __gnu_cxx::new_allocator<_Tp>::pointer   
   > = const std::basic_string*;   
   > __gnu_cxx::new_allocator<_Tp>::size_type = long unsigned int]':   
   >...   
   >Vector_init_const_string.C:8:45: required from here   
   >ext/new_allocator.h:110:30: error: invalid conversion from 'const void*' to   
   'void*' [-fpermissive]   
   > { ::operator delete(__p); }   
   >   
   >In file included   
   >from ext/new_allocator.h:33:0,   
   >...   
   >from string:41,   
   >from Vector_init_const_string.C:1:   
   >new:95:6: error: initializing argument 1 of 'void operator delete(void*)'   
   [-fpermissive]   
   > void operator delete(void*) _GLIBCXX_USE_NOEXCEPT   
   >   
   >In file included   
   > from vector:62:0,   
   > from Vector_init_const_string.C:4:   
   >...   
   >Vector_init_const_string.C:8:45: required from here   
   >   
   >bits/stl_construct.h:75:7: error:   
   > invalid static_cast from type 'const std::basic_string*' to type   
   'void*'   
   > { ::new(static_cast(__p)) _T1(std::forward<_Args>(__args)...);   
   }   
   >*/   
      
   --   
   Remove del for email   
      
      
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
    [ comp.lang.c++.moderated. First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|