I'm going to create a new library that renders genome annotations into charts. However, as C++ doesn't have a centralized library website like Perl, how do I know if the namespace conflicts with any existing one?
2 Answers
No, xd
is not a good name: it's too short. It could be a good alias in a limited context, but for a library that will be used by others, provide a long, descriptive name. Then users can select an alias that makes sense for their project.
namespace my_company {
namespace XnoDraw {
// ...
} // namespace XnoDraw
} // namespace my_company
// user code, not your code:
namespace xd = my_company::XnoDraw;
You could use anything except std
.
Note that c++ doesn't allow compound names for namespaces.
For instance:
// Allowed
namespace a
{
namespace b
{
int c;
}
}
// Not allowed
namespace a::b
{
int c;
}
-
3You have to write
namespace
twice to open two namespaces, but the set of available names is the same either way. Commented Aug 4, 2013 at 11:07
XnoDraw::
, then?xd
make it sound like an internet memelol::
,rly::
andyolo::
,XnoDraw::
is better in my opinion, the only thing to notice is that often times names are patented or protected by the law, so be sure to pick a name that is "free".