what is a good return type ` boost::shared_ptr<StructA>`?
===

The function needs to return a `shared_ptr` pointing to `StructA`.

    struct StructA
    {
        // complicated struct that also holds other sub-structure
    	....
    };

    const boost::shared_ptr<const StructA&>& GetStructA(...)
    {...} #0
    
    const boost::shared_ptr<const StructA>& GetStructA(...)
    {...} #0.5

    const boost::shared_ptr<StructA>& GetStructA(...)
    {...} #1
    
    const boost::shared_ptr<StructA> GetStructA(...)
    {...} #2
    
    boost::shared_ptr<const StructA> 
    {...} #3
    
    boost::shared_ptr<StructA> GetStructA(...)
    {...} #4
    
    boost::shared_ptr<StructA>& GetStructA(...)
    {...} #5

    boost::shared_ptr<StructA&> GetStructA(...)
    {...} #6

There are so many choices and I am sure one of them is best(pls point out if there is anyone left).

Personally, I prefer to using #1
    const boost::shared_ptr<StructA>& GetStructA(...)
    {...} #1

The legacy system uses #2
    const boost::shared_ptr<StructA>  GetStructA(...)
    {...} #2

The reason why I prefer to choosing #0 is as follows:

1> return const shared_ptr, so that the caller of this function should NOT change the returned shared_ptr which may point to internal data structure

2> return by reference, so that I can avoid +/- of the reference count of shared_ptr

3> the shared_ptr holds const StructA&, so that the caller cannot change the content of the const shared_ptr. If I were right, even if the shared_ptr is const, it cannot prevent the caller from changing the pointed data.

Please 
1> correct my understanding I make any mistake
2> provide a best return signature for this function.

Thank you




