S
Steve Hill
Hi,
When compiling under g++ (version 3.2) the following code fragement gives me a
warning:
steve@khan:~/tmp> /opt/bin/g++ -o state_test state_test.cpp
state_test.cpp:42: warning: `typename State<T>::State_change_counter' is
implicitly a typename
state_test.cpp:42: warning: implicit typename is deprecated, please see the
documentation for details
Any ideas why, and how to avoid it?
Best regards
Steve
#include <map>
#include <iterator>
using namespace std;
template <class T>
class State
{
public:
State(T initial_state=T(0))
:state(initial_state)
{};
virtual ~State()
{};
T operator()() const
{ return (T)state; };
void operator=(const T new_state)
{
++state_changes[State_change((T)state, new_state)];
state=(unsigned int)(new_state);
};
bool operator==(const T comp_state) const
{ return state==(unsigned int)(comp_state); };
private:
unsigned int state;
typedef pair<T,T> State_change;
typedef map<State_change, int> State_change_counter;
static State_change_counter state_changes;
};
template <class T>
State<T>::State_change_counter State<T>::state_changes; // WARNING HERE
enum E{ A,B, C };
int main (void)
{
State<E> s;
s = B;
return 0;
}
When compiling under g++ (version 3.2) the following code fragement gives me a
warning:
steve@khan:~/tmp> /opt/bin/g++ -o state_test state_test.cpp
state_test.cpp:42: warning: `typename State<T>::State_change_counter' is
implicitly a typename
state_test.cpp:42: warning: implicit typename is deprecated, please see the
documentation for details
Any ideas why, and how to avoid it?
Best regards
Steve
#include <map>
#include <iterator>
using namespace std;
template <class T>
class State
{
public:
State(T initial_state=T(0))
:state(initial_state)
{};
virtual ~State()
{};
T operator()() const
{ return (T)state; };
void operator=(const T new_state)
{
++state_changes[State_change((T)state, new_state)];
state=(unsigned int)(new_state);
};
bool operator==(const T comp_state) const
{ return state==(unsigned int)(comp_state); };
private:
unsigned int state;
typedef pair<T,T> State_change;
typedef map<State_change, int> State_change_counter;
static State_change_counter state_changes;
};
template <class T>
State<T>::State_change_counter State<T>::state_changes; // WARNING HERE
enum E{ A,B, C };
int main (void)
{
State<E> s;
s = B;
return 0;
}