Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3042

template and Visual : unable to match function definition to an existing declaration

$
0
0
Hi,

Here's a piece of code that compiled with GCC, but not with Visual 2010:

Code:

template < class TPRIORITY, class T >
class cf_list :
    public std::list< std::pair<TPRIORITY, T> >
{
    public:
        ...

        /// \brief Returns a reference to the element referenced by iterator _it.
        T get_value( const typename std::list< std::pair< TPRIORITY, T > >::iterator& _it );

        ...
};


template <class TPRIORITY, class T>
T cf_list<TPRIORITY, T>::get_value(
        const typename std::list< std::pair< TPRIORITY, T > >::iterator& _it
        )
{
    // Second element is the stored value
    return ( *_it ).second;
}

The error is the following:
Code:

cf_list.hpp(230): error C2244: 'cf_core::cf_list<TPRIORITY,T>::get_value' : unable to match function definition to an existing declaration
...
see declaration of 'cf_core::cf_list<TPRIORITY,T>::get_value'
1>          definition
1>          'T cf_core::cf_list<TPRIORITY,T>::get_value(const std::list<std::pair<_Other1,_Other2>>::iterator &)'
1>          existing declarations
1>          'T cf_core::cf_list<TPRIORITY,T>::get_value(const std::_List_iterator<std::_List_val<_Ty,_Alloc>> &)'

Thanks in advance for any ideas...

Viewing all articles
Browse latest Browse all 3042

Trending Articles