• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Question about static members of templated classes.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question about static members of templated classes.


  • Subject: Question about static members of templated classes.
  • From: Brant Sears <email@hidden>
  • Date: Mon, 27 Aug 2007 14:29:57 -0400

Hi. I have a question about static members of a templated class. I am getting an undefined symbols error from the linker.
My templated class:

template <class T> class RefCountPtr
{
public:
RefCountPtr(T *ptr) : p(ptr) {
QMutexLocker lckr(&cmLock);
++countMap[p];
}
~RefCountPtr() {
QMutexLocker lckr(&cmLock);
--countMap[p];
if (countMap[p] == 0) {
delete p;
}
}


T* operator->() {
return p;
}


bool isNull() {
return (NULL==p);
}


private:
T * p;
static QMutex cmLock;
static map<T *, int> countMap;
};

Then in another header, I have this:
typedef RefCountPtr<Credentials> CredentialsPtr

Then in a .cpp file, I have the following:
template <> QMutex RefCountPtr<Credentials>::cmLock;
template <> map<Credentials*, int> RefCountPtr<Credentials>::countMap;

I am seeing the following linker error:

/usr/bin/ld: Undefined symbols:
RefCountPtr<Credentials>::cmLock
RefCountPtr<Credentials>::countMap

I thought I was defining the static members. Any idea why I'm seeing this and what I can do to fix it?

TIA

Brant Sears
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: [SOLVED] Question about static members of templated classes.
      • From: Brant Sears <email@hidden>
  • Prev by Date: IB - Way to copy objects from one NIB instance to another and keep the actions/outlets?
  • Next by Date: Re: [SOLVED] Question about static members of templated classes.
  • Previous by thread: Re: IB - Way to copy objects from one NIB instance to another and keep the actions/outlets?
  • Next by thread: Re: [SOLVED] Question about static members of templated classes.
  • Index(es):
    • Date
    • Thread