G++, compiler warnings, c++ templates
- by Ian
During the compilatiion of the C++ program those warnings appeared:
c:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bc:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_algo.h:2317: instantiated from `void std::partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Object<double>**, std::vector<Object<double>*, std::allocator<Object<double>*> > >, _Compare = sortObjects<double>]'
c:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_algo.h:2506: instantiated from `void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Object<double>**, std::vector<Object<double>*, std::allocator<Object<double>*> > >, _Size = int, _Compare = sortObjects<double>]'
c:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_algo.h:2589: instantiated from `void std::sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Object<double>**, std::vector<Object<double>*, std::allocator<Object<double>*> > >, _Compare = sortObjects<double>]'
io/../structures/objects/../../algorithm/analysis/../../structures/list/ObjectsList.hpp:141: instantiated from `void ObjectsList <T>::sortObjects(unsigned int, T, T, T, T, unsigned int) [with T = double]'
I do not why, because all objects have only template parameter T, their local variables are also T.
The only place, where I am using double is main. There are objects of type double creating and adding into the ObjectsList...
Object <double> o1;
ObjectsList <double> olist;
olist.push_back(o1);
....
T xmin = ..., ymin = ..., xmax = ..., ymax = ...;
unsigned int n = ...;
olist.sortAllObjects(xmin, ymin, xmax, ymax, n);
and comparator
template <class T>
class sortObjects
{
private:
unsigned int n;
T xmin, ymin, xmax, ymax;
public:
sortObjects ( const T xmin_, const T ymin_, const T xmax_, const T ymax_, const int n_ ) :
xmin ( xmin_ ), ymin ( ymin_ ), xmax ( xmax_ ), ymax ( ymax_ ), n ( n_ ) {}
bool operator() ( const Object <T> *o1, const Object <T> *o2 ) const
{
T dmax = (std::max) ( xmax - xmin, ymax - ymin );
T x_max = ( xmax - xmin ) / dmax;
T y_max = ( ymax - ymin ) / dmax;
...
return ....;
}
representing ObjectsList method:
template <class T>
void ObjectsList <T> ::sortAllObjects ( const T xmin, const T ymin, const T xmax, const T ymax, const unsigned int n )
{
std::sort ( objects.begin(), objects.end(), sortObjects <T> ( xmin, ymin, xmax, ymax, n ) );
}