On 22/01/2014 12:44, Quoth Leon Mlakar:
On 21/01/14 23:31, Gavin Lambert wrote:
I've been wondering if a better strategy might be to explicitly typedef or "using" the versions I want into the global namespace (or an "app" namespace) in a common header and then use those everywhere instead. Though this is fragile against a misplaced "using namespace". [...] But your suggestion it the last paragraph is intriguing if combined with using type aliases and explicit namespace for symbols used in applications - something like mytypes::shared_ptr or appdef::string ... it is just a soft of half-baked idea at the moment, For now I'm still scratching at the surface of C++11, but we did use type aliases in past C# projects, and the C++ seem to have the advantage of allowing aliases for template classes. I'll give this some thought in the future. I really wonder what sorts of patterns will emerge from this.
Yes, one of the reasons why I haven't been using that strategy thus far is that most of the code I work with is still C++03, and lacks the ability to define a "simple" alias for a templated type(*) -- and most of the types I'd want to do this with are templates (containers and smart pointers). (*) I don't consider having to use "select_my_vector<T>::type" sufficiently simple, vs. "my::vector<T>" -- especially when I don't want client code to have to care/change whether this is a typedef or a reimplementation.