Boost logo

Boost Users :

From: Zhuo Hao (hzhuo1_at_[hidden])
Date: 2006-07-15 00:15:45


But consider the following code:
#include<iostream>
using namespace std;

class CMutex{};//Hide all the implementations for convience

template<class Y>
void world(Y * p)
{

}

void hello(int *x){

}

int main(){
    hello(0);
    world<CMutex>(0);
    return 1;
}
It compiles and runs without problems.So you see I can pass zero as a
pointer to Y, and as a pointer to int. That's OK.
I wonder how it is implemented that we cannot pass zero as a pointer to Y in
the constructor of shared_ptr.

Thanks
Zhuo Hao

On 14/07/06, Tommy Hinks <tommy.hinks_at_[hidden]> replied:
You can't pass 0 because the Type passed must be an Investment*, not
just a type that could be cast to one. This is why you have to
explicitly cast it yourself.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net