ambiguous std::fill with character array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello

Consider this snipped
<code>
#include <string>
#include <vector>
#include <algorithm>

int main() {
  std::vector<std::string> foo(20);  
  std::fill(foo.begin(), foo.end(), "bar");
}
</code>

g++-4.2.3 compiles it, but 4.3.0 gives the attached error message.  

The solution is to use
  std::fill(array.begin(), array.end(), std::string("interpolateboundary"));

My question: Is it a bug or by intention?

Thanks,
 -- Maik
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/../../../../include/c++/4.3.0/bits/stl_algobase.h: In function 'void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = __gnu_cxx::__normal_iterator<std::basic_string<char, std::char_traits<char>, std::allocator<char> >*, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >, _Tp = char [4]]':
/home/maik/workspace/tester/gcc43/fill.cpp:7:   instantiated from here
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/../../../../include/c++/4.3.0/bits/stl_algobase.h:726: error: call of overloaded '__fill_a(std::basic_string<char, std::char_traits<char>, std::allocator<char> >*, std::basic_string<char, std::char_traits<char>, std::allocator<char> >*, const char [4])' is ambiguous
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/../../../../include/c++/4.3.0/bits/stl_algobase.h:683: note: candidates are: typename __gnu_cxx::__enable_if<(! std::__is_scalar::__value), void>::__type std::__fill_a(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = std::basic_string<char, std::char_traits<char>, std::allocator<char> >*, _Tp = char [4]]
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/../../../../include/c++/4.3.0/bits/stl_algobase.h:692: note:                 typename __gnu_cxx::__enable_if<std::__is_scalar::__value, void>::__type std::__fill_a(_ForwardIterator, _ForwardIterator, _Tp) [with _ForwardIterator = std::basic_string<char, std::char_traits<char>, std::allocator<char> >*, _Tp = const char*]
make[2]: *** [CMakeFiles/fill.dir/fill.cpp.o] Error 1
make[1]: *** [CMakeFiles/fill.dir/all] Error 2
make: *** [all] Error 2

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux