Well, this question has changed a bit, and I want to try to start (with) the main goals that I am shooting for:
- Create library code that wraps legacy C-language entities when collecting C ++ resources, initializes, and also provides a basic or better exception guarantee.
- Enable clients of this code to use it in a very natural C ++ mode without creating a lot of overhead for existing code in order to convert it to using C ++ shell objects (i.e. automatically convert to the corresponding types of obsolete objects, constructors, which use legacy types, etc.)
- Limit the influence of namespace on library code. Ideally, a library would have several namespaces that provide related functions that limit the scope and impact of using type X declarations of the namespace — much like acceleration libraries do (i.e. use part namespaces to enter only those characters that they wisely want to use and hide those that are implementation details, as well as limit the scope of possible new values to existing characters in order to avoid unexpected implicit conversions to the inside When the user code).
- Require customers to explicitly request those parts of the library that they actually want to enter into their code base. This goes hand in hand with limiting the impact of including library headers. Client code should have a reasonable level of control over which parts of the library will be automatically used to resolve names when compiling their code.
- - . , typedefs, . : , , , . , , , "".
...
, C N. C Free. , C , C .
. N, C, , , C, .
, - :
namespace N {
void free(THING * thing);
class C
{
public:
... details omitted...
free()
{
free(m_thing);
}
}
}
N:: free (m_thing). . , , ( )?
, N:: free , , . , (, dispose). , , , , , .
. , . , , , ( ) - - , , , .
, , ?
EDIT:
, :
namespace Toolbox {
namespace Windows {
void Free(ITEMIDLIST ** ppidl);
class Pidl
{
public:
Pidl() : m_pidl(NULL) { }
explicit Pidl(const ITEMIDLIST * pidl);
explicit Pidl(IShellFolder * folder);
...
void Free();
};
, ITEMIDLIST * CoTaskMemFree(). Pidl , Windows Shell.h, .
, , - COM Windows. Toolbox , , Toolbox:: Windows windows-y, ..
++, , ( ). - koenig ( ITEMIDLIST Toolbox:: Windows), ! . , , , Toolbox, , ( Win32 , , - GLOBAL NS - : / //).
, . : , NS , , , NS, (.. -, )?
: , , , , :
using namespace X {
code here...
}
, , X , , .