473,473 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Compilation error

I'm implementing an algorithm that will fill a container with the same
item. However, my object creation function isn't working correctly.
This should auto detect the types based on the parameters it was passed.
But I must be missing something as it will not compile.

template<typename dest_t, typename src_t>
inline fill<dest_t, src_tmake_fill(dest_t& dest, src_t& src) //< error
{
return fill<dest_t, src_t>(src);
}

.../arrayTest1.h:68: error: expected init-declarator before '<' token
.../arrayTest1.h:68: error: expected `;' before '<' token

Thanks in advance.
Adrian
--
__________________________________________________ ___________________
\/Adrian_Hawryluk BSc. - Specialties: UML, OOPD, Real-Time Systems\/
\ My newsgroup writings are licensed under the Creative Commons /
\ Attribution-Noncommercial-Share Alike 3.0 License /
\_____[http://creativecommons.org/licenses/...sa/3.0/]_____/
\/______[blog:__http://adrians-musings.blogspot.com/]______\/
Mar 19 '07 #1
9 2753
Adrian Hawryluk wrote:
I'm implementing an algorithm that will fill a container with the same
item. However, my object creation function isn't working correctly.
This should auto detect the types based on the parameters it was passed.
But I must be missing something as it will not compile.

template<typename dest_t, typename src_t>
inline fill<dest_t, src_tmake_fill(dest_t& dest, src_t& src) //< error
{
return fill<dest_t, src_t>(src);
}

../arrayTest1.h:68: error: expected init-declarator before '<' token
../arrayTest1.h:68: error: expected `;' before '<' token

Thanks in advance.
Oh, here is the fill class that goes with it:

template <typename dest_t, typename src_t>
class fill
{
src_t const & value;
public:
fill(src_t const & value)
: value(value) {}

fill(fill const & f) : value(f.value) {}

void operator()(dest_t& dest)
{
// copy here
}
};
Adrian
--
__________________________________________________ ___________________
\/Adrian_Hawryluk BSc. - Specialties: UML, OOPD, Real-Time Systems\/
\ My newsgroup writings are licensed under the Creative Commons /
\ Attribution-Noncommercial-Share Alike 3.0 License /
\_____[http://creativecommons.org/licenses/...sa/3.0/]_____/
\/______[blog:__http://adrians-musings.blogspot.com/]______\/
Mar 19 '07 #2
Adrian Hawryluk wrote:
I'm implementing an algorithm that will fill a container with the same
item. However, my object creation function isn't working correctly.
This should auto detect the types based on the parameters it was passed.
But I must be missing something as it will not compile.

template<typename dest_t, typename src_t>
inline fill<dest_t, src_tmake_fill(dest_t& dest, src_t& src) //< error
{
return fill<dest_t, src_t>(src);
}

../arrayTest1.h:68: error: expected init-declarator before '<' token
../arrayTest1.h:68: error: expected `;' before '<' token
Look at the declaration immediately before the make_fill declaration.
Are you by any chance missing a semicolon?
Mar 19 '07 #3
red floyd wrote:
Adrian Hawryluk wrote:
>I'm implementing an algorithm that will fill a container with the same
item. However, my object creation function isn't working correctly.
This should auto detect the types based on the parameters it was
passed. But I must be missing something as it will not compile.

template<typename dest_t, typename src_t>
inline fill<dest_t, src_tmake_fill(dest_t& dest, src_t& src) //< error
{
return fill<dest_t, src_t>(src);
}

../arrayTest1.h:68: error: expected init-declarator before '<' token
../arrayTest1.h:68: error: expected `;' before '<' token

Look at the declaration immediately before the make_fill declaration.
Are you by any chance missing a semicolon?
Checked that already. The fill class that I posted is directly before
this function.
Adrian
--
__________________________________________________ ___________________
\/Adrian_Hawryluk BSc. - Specialties: UML, OOPD, Real-Time Systems\/
\ My newsgroup writings are licensed under the Creative Commons /
\ Attribution-Noncommercial-Share Alike 3.0 License /
\_____[http://creativecommons.org/licenses/...sa/3.0/]_____/
\/______[blog:__http://adrians-musings.blogspot.com/]______\/
Mar 19 '07 #4
Adrian Hawryluk wrote:
I'm implementing an algorithm that will fill a container with the same
item. However, my object creation function isn't working correctly.
This should auto detect the types based on the parameters it was passed.
But I must be missing something as it will not compile.

template<typename dest_t, typename src_t>
inline fill<dest_t, src_tmake_fill(dest_t& dest, src_t& src) //< error
{
return fill<dest_t, src_t>(src);
}

../arrayTest1.h:68: error: expected init-declarator before '<' token
../arrayTest1.h:68: error: expected `;' before '<' token

Thanks in advance.
Adrian
I don't get it. Under VC++ 6.0 it works (and that doesn't accept a
whole lot ;) lol jk) but g++ 3.4.4 (cygming special, gdc 0.12, using dmd
0.125), it chokes. Here is my test code that I transfered between the
two compilers. Nothing else in the file but this, so the only thing
that would go wrong is a link error because there is no main() function.

--------------------------------------------------------------------------
#include <vector>
#include <algorithm>
using namespace std;
template <typename dest_t, typename src_t>
class fill
{
src_t const & value;
public:
fill(src_t const & value)
: value(value) {}

void operator()(dest_t& dest)
{
}
};

template<typename dest_t, typename src_t>
inline fill<dest_t, src_t constmake_fill(dest_t& dest, src_t& src)
{
return fill<dest_t, src_t const>(src);
}

int main2(int argc, char* argv[])
{

vector<intaa;
aa.push_back(3);
aa.push_back(5);
int b = 3;
for_each(aa.begin(), aa.end(), make_fill(*aa.begin(), b));

return 0;
}
--------------------------------------------------------------------------
This is driving me nuts.
Adrian
--
__________________________________________________ ___________________
\/Adrian_Hawryluk BSc. - Specialties: UML, OOPD, Real-Time Systems\/
\ My newsgroup writings are licensed under the Creative Commons /
\ Attribution-Noncommercial-Share Alike 3.0 License /
\_____[http://creativecommons.org/licenses/...sa/3.0/]_____/
\/______[blog:__http://adrians-musings.blogspot.com/]______\/
Mar 20 '07 #5
Adrian Hawryluk wrote:
Adrian Hawryluk wrote:
>I'm implementing an algorithm that will fill a container with the same
item. However, my object creation function isn't working correctly.
This should auto detect the types based on the parameters it was
passed. But I must be missing something as it will not compile.

template<typename dest_t, typename src_t>
inline fill<dest_t, src_tmake_fill(dest_t& dest, src_t& src) //< error
{
return fill<dest_t, src_t>(src);
}

../arrayTest1.h:68: error: expected init-declarator before '<' token
../arrayTest1.h:68: error: expected `;' before '<' token

Thanks in advance.
Adrian

I don't get it. Under VC++ 6.0 it works (and that doesn't accept a
whole lot ;) lol jk) but g++ 3.4.4 (cygming special, gdc 0.12, using dmd
0.125), it chokes. Here is my test code that I transfered between the
two compilers. Nothing else in the file but this, so the only thing
that would go wrong is a link error because there is no main() function.

--------------------------------------------------------------------------
#include <vector>
#include <algorithm>
using namespace std;
template <typename dest_t, typename src_t>
class fill
{
src_t const & value;
public:
fill(src_t const & value)
: value(value) {}

void operator()(dest_t& dest)
{
}
};

template<typename dest_t, typename src_t>
inline fill<dest_t, src_t constmake_fill(dest_t& dest, src_t& src)
{
return fill<dest_t, src_t const>(src);
}

int main2(int argc, char* argv[])
{

vector<intaa;
aa.push_back(3);
aa.push_back(5);
int b = 3;
for_each(aa.begin(), aa.end(), make_fill(*aa.begin(), b));

return 0;
}
--------------------------------------------------------------------------
Don't know if it makes much of a diff, but change the second parameter
of make_fill to src_t const& src.
Mar 20 '07 #6
* Adrian Hawryluk:
>
#include <vector>
#include <algorithm>
using namespace std;
template <typename dest_t, typename src_t>
class fill
{
src_t const & value;
public:
fill(src_t const & value)
: value(value) {}

void operator()(dest_t& dest)
{
}
};

template<typename dest_t, typename src_t>
inline fill<dest_t, src_t constmake_fill(dest_t& dest, src_t& src)
{
return fill<dest_t, src_t const>(src);
}

int main2(int argc, char* argv[])
{

vector<intaa;
aa.push_back(3);
aa.push_back(5);
int b = 3;
for_each(aa.begin(), aa.end(), make_fill(*aa.begin(), b));

return 0;
}
--------------------------------------------------------------------------
This is driving me nuts.
'fill' is a standard library template function.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Mar 20 '07 #7
Alf P. Steinbach wrote:
* Adrian Hawryluk:
>>
#include <vector>
#include <algorithm>
using namespace std;
template <typename dest_t, typename src_t>
class fill
{
src_t const & value;
public:
fill(src_t const & value)
: value(value) {}
void operator()(dest_t& dest)
{
}
};

template<typename dest_t, typename src_t>
inline fill<dest_t, src_t constmake_fill(dest_t& dest, src_t& src)
{
return fill<dest_t, src_t const>(src);
}

int main2(int argc, char* argv[])
{
vector<intaa;
aa.push_back(3);
aa.push_back(5);
int b = 3;
for_each(aa.begin(), aa.end(), make_fill(*aa.begin(), b));

return 0;
}
--------------------------------------------------------------------------

This is driving me nuts.

'fill' is a standard library template function.
Yeah *sigh*, I just figured that out. I wish that the error message
came up on the class, and not on the function though.
Adrian
--
__________________________________________________ ___________________
\/Adrian_Hawryluk BSc. - Specialties: UML, OOPD, Real-Time Systems\/
\ My newsgroup writings are licensed under the Creative Commons /
\ Attribution-Noncommercial-Share Alike 3.0 License /
\_____[http://creativecommons.org/licenses/...sa/3.0/]_____/
\/______[blog:__http://adrians-musings.blogspot.com/]______\/
Mar 20 '07 #8
Adrian Hawryluk wrote:
Alf P. Steinbach wrote:
>* Adrian Hawryluk:
>>>
#include <vector>
#include <algorithm>
using namespace std;
template <typename dest_t, typename src_t>
class fill
{
src_t const & value;
public:
fill(src_t const & value)
: value(value) {}
void operator()(dest_t& dest)
{
}
};

template<typename dest_t, typename src_t>
inline fill<dest_t, src_t constmake_fill(dest_t& dest, src_t& src)
{
return fill<dest_t, src_t const>(src);
}

int main2(int argc, char* argv[])
{
vector<intaa;
aa.push_back(3);
aa.push_back(5);
int b = 3;
for_each(aa.begin(), aa.end(), make_fill(*aa.begin(), b));

return 0;
}
--------------------------------------------------------------------------

This is driving me nuts.

'fill' is a standard library template function.

Yeah *sigh*, I just figured that out. I wish that the error message
came up on the class, and not on the function though.
BTW, thanks for the help.
Adrian
--
__________________________________________________ ___________________
\/Adrian_Hawryluk BSc. - Specialties: UML, OOPD, Real-Time Systems\/
\ My newsgroup writings are licensed under the Creative Commons /
\ Attribution-Noncommercial-Share Alike 3.0 License /
\_____[http://creativecommons.org/licenses/...sa/3.0/]_____/
\/______[blog:__http://adrians-musings.blogspot.com/]______\/
Mar 20 '07 #9
Adrian Hawryluk wrote:
Alf P. Steinbach wrote:
>'fill' is a standard library template function.

Yeah *sigh*, I just figured that out. I wish that the error message
came up on the class, and not on the function though.
Adrian
BTW, thanks for the help.
Adrian
--
__________________________________________________ ___________________
\/Adrian_Hawryluk BSc. - Specialties: UML, OOPD, Real-Time Systems\/
\ My newsgroup writings are licensed under the Creative Commons /
\ Attribution-Noncommercial-Share Alike 3.0 License /
\_____[http://creativecommons.org/licenses/...sa/3.0/]_____/
\/______[blog:__http://adrians-musings.blogspot.com/]______\/
Mar 20 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: konf | last post by:
Hallo, I tried to compile PGSQL 7.4 and I got error (durring make): ar: command not found What is it? Whe I can found it? I have: $ uname -a SunOS ... 5.8 Generic_108528-03 sun4u sparc...
10
by: Sune | last post by:
Hi, previously I used Eclipse CDT for compiling my files just to get started with C and leave C++ behind. Now it's time to get a little more serious so I've moved my files to a new workplace and...
6
by: Joachim | last post by:
I made some project changes (which seems it doesn't help if I undo) which have created compilation error: " Server Error in '/PCSWebApp1' Application....
2
by: James Zhuo | last post by:
Hi all I've been getting the following compilation error. I should explain the background of the project that i am taking over. This is a project that has been developed by someone else a while...
0
by: James Zhuo | last post by:
hi all I changed the name of the class LoginPage to a different name "LoginPageOne" But the same error gets generated with the Wiliam.Request.LoginPageOne. That pretty much leaves me clueless...
3
by: Dan | last post by:
Hi, I have a problem using an aspx page with a Control on it. I get the following error message Compiler Error Message: CS1595: 'Test.Class2' is defined in multiple places; using definition...
6
by: Plat | last post by:
I've Googled this for a while, to no avail. Hopefully someone can help me. Maybe I'm using the wrong terminology. Here's the scoop! Let's say I've got a simple *.ASPX page that has a syntax...
3
by: Robert | last post by:
I have a number of web projects converted from 1.1 to 2.0 in VS2005. I am methodically seeing the error below: The element 'compilation' has invalid child element 'compilers'. List of...
0
by: Stimp | last post by:
I've created an aspx page called HistoryManage.aspx. The page works fine on my local machine but when I load it off the web I get the following strange error... Compilation Error...
1
by: BSand0764 | last post by:
I'm getting an error that I can't seem to resolve. When I compile the Functor related logic in a test program, the files compile and execute properly (see Listing #1). However, when I...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.