Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > template compile error

Reply
Thread Tools

template compile error

 
 
ken.carlino@gmail.com
Guest
Posts: n/a
 
      02-26-2006
I would need some help in figuring out this compile error. Thanks in
advance for any help.

I have a template like this:
template <class T, class T1>
class Dummy {
public:
float buildList(T& tmpAreaPerCent, const T& allAreaPerCent, int no);

};

template<class T, class T1>
float Dummy<T, T1>::buildList(T& tmpAreaPerCent, const T&
allAreaPerCent, int no) {

vector<int> allItr;

allItr.push_back(0);

int size = tmpAreaPerCent.size() - 1;
allItr.push_back(size);

sort(allItr.begin(), allItr.end());

for (int i = 0; i + 1 < allItr.size() ; i++) {
int beginIndex = allItr[i];

if (i != 0) beginIndex += 1;

int endIndex = allItr[i+1];
// comment calling method here
}
return 0.0;
};

This is where I create the template:
Dummy< vector<float>, float > pmh2;
float areaStdDev = pmh2.buildList(tmpAreaPerCent, allAreaPerCent,
no);

Here is the error:
.../MatcherHelper.h: In member function 'float Dummy<T,
T1>::buildList(T&, const T&, int) [with T = std::vector<float,
std::allocator<float> >, T1 = float]':
.../Row1Matcher.cpp:41: instantiated from here
.../PatternMatcherHelper.h:36: warning: comparison between signed and
unsigned integer expressions
.../Row1Matcher.cpp:41: instantiated from here

Thank you

 
Reply With Quote
 
 
 
 
Amadeus W. M.
Guest
Posts: n/a
 
      02-26-2006
On Sat, 25 Feb 2006 17:59:20 -0800, ken.carlino wrote:

> I would need some help in figuring out this compile error. Thanks in
> advance for any help.
>
> I have a template like this:
> template <class T, class T1>
> class Dummy {
> public:
> float buildList(T& tmpAreaPerCent, const T& allAreaPerCent, int no);
>
> };
>
> template<class T, class T1>
> float Dummy<T, T1>::buildList(T& tmpAreaPerCent, const T&
> allAreaPerCent, int no) {
>
> vector<int> allItr;
>
> allItr.push_back(0);
>
> int size = tmpAreaPerCent.size() - 1;
> allItr.push_back(size);
>
> sort(allItr.begin(), allItr.end());
>
> for (int i = 0; i + 1 < allItr.size() ; i++) {
> int beginIndex = allItr[i];
>
> if (i != 0) beginIndex += 1;
>
> int endIndex = allItr[i+1];
> // comment calling method here
> }
> return 0.0;
> };
>
> This is where I create the template:
> Dummy< vector<float>, float > pmh2;
> float areaStdDev = pmh2.buildList(tmpAreaPerCent, allAreaPerCent,
> no);
>
> Here is the error:
> ../MatcherHelper.h: In member function 'float Dummy<T,
> T1>::buildList(T&, const T&, int) [with T = std::vector<float,
> std::allocator<float> >, T1 = float]':
> ../Row1Matcher.cpp:41: instantiated from here
> ../PatternMatcherHelper.h:36: warning: comparison between signed and
> unsigned integer expressions
> ../Row1Matcher.cpp:41: instantiated from here
>
> Thank you



It's a warning, not an error. Go to line 36 in PatternMatcherHelper.h
(as the warning says), and see which integers you're comparing. It may or
may not matter.

 
Reply With Quote
 
 
 
 
benben
Guest
Posts: n/a
 
      02-26-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> I would need some help in figuring out this compile error. Thanks in
> advance for any help.
>
> I have a template like this:
> template <class T, class T1>
> class Dummy {
> public:
> float buildList(T& tmpAreaPerCent, const T& allAreaPerCent, int no);
>
> };
>
> template<class T, class T1>
> float Dummy<T, T1>::buildList(T& tmpAreaPerCent, const T&
> allAreaPerCent, int no) {
>
> vector<int> allItr;
>
> allItr.push_back(0);
>
> int size = tmpAreaPerCent.size() - 1;
> allItr.push_back(size);
>
> sort(allItr.begin(), allItr.end());
>
> for (int i = 0; i + 1 < allItr.size() ; i++) {



for (vector<int>::size_type i = 0; ...

// vector<int>::size_type is unsigned

> int beginIndex = allItr[i];
>
> if (i != 0) beginIndex += 1;
>
> int endIndex = allItr[i+1];
> // comment calling method here
> }
> return 0.0;
> };
>
> This is where I create the template:
> Dummy< vector<float>, float > pmh2;
> float areaStdDev = pmh2.buildList(tmpAreaPerCent, allAreaPerCent,
> no);
>
> Here is the error:
> ../MatcherHelper.h: In member function 'float Dummy<T,
> T1>::buildList(T&, const T&, int) [with T = std::vector<float,
> std::allocator<float> >, T1 = float]':
> ../Row1Matcher.cpp:41: instantiated from here
> ../PatternMatcherHelper.h:36: warning: comparison between signed and
> unsigned integer expressions


Isn't the above warning obvious? Go to line 36 and find out about signed
and unsigned integer.

> ../Row1Matcher.cpp:41: instantiated from here
>
> Thank you
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to compile the following source code in VC6// I have error inVC++6 but compile ok in GCC fAnSKyer C++ 2 06-07-2009 07:57 AM
error: expected `;' before 'itr' template compile error? Solaris vsLinux Jeff C++ 3 03-11-2008 08:29 PM
cant compile on linux system.cant compile on cant compile onlinux system. Nagaraj C++ 1 03-01-2007 11:18 AM
Compiler error occurred when try to use a flexible template expression in preprocessor definesCompiler error occurred when try to use a flexible template expression in preprocessor defines snnn C++ 6 03-14-2005 04:09 PM
Explicit template instantiation from template function doesn't compile? Fernando Cuenca C++ 4 09-06-2004 04:06 PM



Advertisments