Opened 11 years ago

Closed 11 years ago

#649 closed defect (fixed)

compilation error with gcc 3.4

Reported by: Peter Owned by: Peter
Priority: major Milestone: yat 0.7.1
Component: build Version: 0.7
Keywords: Cc:


I get the following error with gcc version 3.4.6 20060404 (Red Hat 3.4.6-11) In constructor `theplu::yat::statistics::Histogram::Histogram(std::istream&)': error: call of overloaded `load(std::basic_istream<char, std::char_traits<char> >&, std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&)' is ambiguous
../../yat/utility/utility.h:284: note: candidates are: void theplu::yat::utility::load(std::istream&, std::vector<std::vector<T, std::allocator<_CharT> >, std::allocator<std::vector<T, std::allocator<_CharT> > > >&, char, char, bool, bool) [with T = double]
../../yat/utility/utility.h:316: note:                 void theplu::yat::utility::load(std::istream&, std::vector<T, std::allocator<_CharT> >&, char) [with T = std::vector<double, std::allocator<double> >

Change History (3)

comment:1 Changed 11 years ago by Peter

The problem is that we call

load(is, data);

where is is an istream and data is a vector<vector<double> >.

There are two load functions and the compiler cannot decide which one to use. First there is a

template<typename T>
void load(std::istream& is, 
          std::vector<std::vector<T> >& vec, 
          char sep='\0', 
          char line_sep='\n', 
          bool ignore_empty=false, 
          bool rectangle=true);

and later in same file there is a

template<typename T>
void load(istream& is, vector<T>& vec, char sep='\0');

We want to use the first function (with T=double), but the compiler argues it could also use the second function with T=vector<double>.

I have experienced no problem with GCC 4.0 or GCC 4.3.

comment:2 Changed 11 years ago by Peter

FWIW, I have no problem with

gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48)

comment:3 Changed 11 years ago by Peter

Resolution: fixed
Status: newclosed

(In [2405]) help compiler choose correct load function. fixes #649

Note: See TracTickets for help on using tickets.