473,487 Members | 2,711 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ISO C++ compile error

Using Dev-C++ 4.9.8.5 I get error:

Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\winroot\src\c++\stupid_tricks\functor_trick.cp p" -o
"C:\winroot\src\c++\stupid_tricks\functor_trick.ex e"
-I"C:\DEV-CPP\include\c++" -I"C:\DEV-CPP\include\c++\mingw32"
-I"C:\DEV-CPP\include\c++\backward" -I"C:\DEV-CPP\include"
-L"C:\DEV-CPP\lib"
C:/winroot/src/c++/stupid_tricks/functor_trick.cpp: In member function
`get_result_type<Base, T, U>::result_type X<Base,
void>::operator()(const
T&, const U&)':
C:/winroot/src/c++/stupid_tricks/functor_trick.cpp:47: warning:
`typename
get_template_parameter<Base, T, U>::result_type' is implicitly a
typename

C:/winroot/src/c++/stupid_tricks/functor_trick.cpp:47: warning:
implicit
typename is deprecated, please see the documentation for details

C:/winroot/src/c++/stupid_tricks/functor_trick.cpp: In function `int
main(int,
char**)':
C:/winroot/src/c++/stupid_tricks/functor_trick.cpp:59: `multiplies'
undeclared

(first use this function)
C:/winroot/src/c++/stupid_tricks/functor_trick.cpp:59: (Each
undeclared
identifier is reported only once for each function it appears in.)
C:/winroot/src/c++/stupid_tricks/functor_trick.cpp:59: template
argument 1 is
invalid
C:/winroot/src/c++/stupid_tricks/functor_trick.cpp:59: ISO C++ forbids
declaration of `x' with no type
C:/winroot/src/c++/stupid_tricks/functor_trick.cpp:60: template
argument 1 is
invalid
C:/winroot/src/c++/stupid_tricks/functor_trick.cpp:60: ISO C++ forbids
declaration of `y' with no type
C:/winroot/src/c++/stupid_tricks/functor_trick.cpp:61: `plus'
undeclared (first
use this function)
C:/winroot/src/c++/stupid_tricks/functor_trick.cpp:61: template
argument 1 is
invalid
C:/winroot/src/c++/stupid_tricks/functor_trick.cpp:61: ISO C++ forbids
declaration of `z' with no type
C:/winroot/src/c++/stupid_tricks/functor_trick.cpp:62: template
argument 1 is
invalid
C:/winroot/src/c++/stupid_tricks/functor_trick.cpp:62: ISO C++ forbids
declaration of `t' with no type
C:/winroot/src/c++/stupid_tricks/functor_trick.cpp:65: `x' cannot be
used as a
function
C:/winroot/src/c++/stupid_tricks/functor_trick.cpp:66: `y' cannot be
used as a
function
C:/winroot/src/c++/stupid_tricks/functor_trick.cpp:67: `y' cannot be
used as a
function
C:/winroot/src/c++/stupid_tricks/functor_trick.cpp:68: `z' cannot be
used as a
function
C:/winroot/src/c++/stupid_tricks/functor_trick.cpp:69: `t' cannot be
used as a
function
C:/winroot/src/c++/stupid_tricks/functor_trick.cpp:70: `t' cannot be
used as a
function

C:/winroot/src/c++/stupid_tricks/functor_trick.cpp:73: `t' cannot be
used as a
function
C:/winroot/src/c++/stupid_tricks/functor_trick.cpp:74: `t' cannot be
used as a
function

Execution terminated
Here is the code:

#include <functional>
#include <iostream>

// handle mixed type operations by selecting a "winning" type to
promote to
// By default this should be symmetric.
template <class T, class U> struct promote : public promote<U,T> { };
template <class T> struct promote<T,T> { typedef T result_type; };
template <> struct promote<double,int>{ typedef double result_type; };
// get result type from a templated binary functor with one template
parameter.
template <template <class> class F, class T, class U >
struct get_result_type
{
typedef typename promote<T,U>::result_type result_type;
};
// given a binary functor F with one template parameter, what template
parameter
// should we instantiate it with if we want to call it on types T and
U ?
template <template <class> class F, class T, class U >
struct get_template_parameter
{
typedef typename promote<T,U>::result_type result_type;
};
template <template <class> class Base, class T > struct X : public
Base<T> {};
template <template <class> class Base>
struct X<Base,void>
{
template <class T>
T operator() (const T& arg)
{
return Base<T>()(arg);
}

template <class T>
T operator() (const T& left, const T& right)
{
return Base<T>()(left,right);
}

template <class T, class U>
typename get_result_type<Base,T,U>::result_type operator()
(const T& left, const U& right)
{
return
Base<get_template_parameter<Base,T,U>::result_type >()
(left,right);
}
};
int main(int argc, char** argv)
{
X<multiplies,double> x;
X<multiplies,void> y;
X<plus,int> z;
X<plus,void> t;
std::cout << x(2,3.4) << std::endl;
std::cout << y(2.,3.4) << std::endl;
std::cout << y(2,3) << std::endl;
std::cout << z(2,3) << std::endl;
std::cout << t(2,3) << std::endl;
std::cout << t(2.1,3.) << std::endl;

// works because of promotes template
std::cout << t(2.1,3) << std::endl;
std::cout << t(2,3.4) << std::endl;

system("PAUSE");

}
Zach
Jul 22 '05 #1
0 1634

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

Similar topics

4
2204
by: Danny Boelens | last post by:
Hi all, today I ran into a compile error after a compiler upgrade. I made a small example to demonstrate my compile error: template<typename T1, typename T2> class A {}; class B
5
3297
by: Carmine Cairo | last post by:
Hi, I'm working on a project and today I've note a little problem during the compile fase. Here a little piece of code: // 1st version welldone = 0; size = p->getSize(); backbone = new...
5
3784
by: Brice Prunier | last post by:
Here under 4 schemas i'm working with ( it may be long: sorry...) The context is the following : Resident.xsd imports Person.xsd and includes Common.xsd ( anonimous schema: no TargetNamespace )...
10
19688
by: Chris LaJoie | last post by:
Our company has been developing a program in C# for some time now, and we haven't had any problems with it, but just last night something cropped up that has me, and everyone else, stumped. I...
6
2833
by: Thomas Connolly | last post by:
I have 2 pages referencing the same codebehind file in my project. Originally the pages referenced separate code behind files. Once I changed the reference to the same file, everything worked...
0
1875
by: Jim Heavey | last post by:
Internal Compiler Error: stage 'BEGIN' Hello, I had an application which was working just fine and I decided to modify all database access within the application to utilizie a new Namespace that I...
9
3485
by: ThunderMusic | last post by:
Hi, I'd like to create a compile time error in my class... maybe there's a way already built in in the framework so I can achieve what I want... I have 2 constructors in my class. One of them...
4
1829
by: tony | last post by:
Hello! My question is about calling this method CollectData below but I get a compile error that I shouldn't have because the type parameter is correct. The compile error is the following:...
5
5021
by: wong_powah | last post by:
#include <vector> #include <iostream> using std::cout; using std::vector; enum {DATASIZE = 20}; typedef unsigned char data_t;
2
4116
by: BruceWho | last post by:
I downloaded boost1.35.0 and built it with following command: bjam --toolset=msvc-7.1 --variant=release --threading=multi -- link=shared --with-system stage and it failed to compile, error...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7181
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...
1
4874
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
4565
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
3076
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
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1381
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 ...
1
600
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
267
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.