Reputation: 917
So I've got template class (abbreviated) like:
template <typename keyT, typename valueT>
class hashMap {
public:
using dataT = pair<keyT,valueT>;
using maybeT = optional<dataT>;
maybeT notFound = optional<dataT> ();
maybeT find(keyT &v);
<snip>
};
When I try to define find(), I have
template <typename keyT, typename valueT>
hashMap::maybeT hashMap<keyT,valueT>::find(keyT &k)
{
and hashMap::maybeT isn't recognized ("expected a class or namespace"). Qualifying hashMap with keyT and valueT doesn't help, either.
How can I export these aliases (or typedefs, if there is a way to make that work).
Upvotes: 0
Views: 57
Reputation: 476970
You need to disambiguate the dependent name:
template <typename keyT, typename valueT>
typename hashMap<keyT, valueT>::maybeT hashMap<keyT,valueT>::find(keyT &k)
// ^^^^^
{
// ...
}
(Since you're writing a template, you might as well keep everything inline, though, and cut down on the code noise. Otherwise you should add inline
to the member function declaration.)
Upvotes: 2