I am creating my own implementation of a weak/strong reference pointer relationship and I am confused to the configuration. When I have a class that contains the strong reference, and I want to set the strong pointer to another class that has a weak reference, should I be passing in the pointer of a weak_ref pointer?
If someone could please take a look at this code and let me know I will appriciate it, also if you notice any other issues please let me know. I put the three files into codepad files so this page does not become cumbersome.
WeakReference.h : http://codepad.org/nNtRk4vO
StrongReference.h : http://codepad.org/MGi0fZ4J
Please do not turn this into a "use boost, use std, use tr1" argument, I am looking for help on this code, not using something else.
The implementations that I have seen, and that I have worked on, that use the concepts of strong and weak reference, all use two counts. Sometimes one count is the number of weak references and the other is the number of strong. Other times one of the counts represents the sum of strong + weak references. Sometimes there are other schemes. But I have not yet seen an implementation with only one count as yours seems to have.
Perhaps it would help if you wrote a specification for exactly what the behavior for strong_ref and weak_ref are supposed to be. I find that the act of writing a specification can actually aid in the debugging of the implementation. It forces you to think about inputs, outputs, corner cases, invalid cases, etc.