C++ 在接口头文件中使用typedef是一种不好的做法吗?

C++ 在接口头文件中使用typedef是一种不好的做法吗?,c++,C++,我知道在头文件中使用“usingnamespace xxx”是一种不好的做法,但是在接口头文件中的typedef呢 例如: typedef std::set<unsigned int> rsids_type; //!< typedef something. struct IRsids { virtual const rsids_type& GetRsids() = 0; } typedef std::set rsid_type;/!

我知道在头文件中使用“usingnamespace xxx”是一种不好的做法,但是在接口头文件中的typedef呢

例如:

typedef std::set<unsigned int> rsids_type;    //!< typedef something.
struct IRsids 
{
    virtual const rsids_type& GetRsids() = 0;
}
typedef std::set rsid_type;/!<键入定义。
结构IRsids
{
虚拟常量rsids_type&GetRsids()=0;
}
根据我的选择,我认为这也是一种不好的做法,因为我们将名称“rsids_type”导入全局名称空间?那么下面的动作呢

struct IRsids 
{
    typedef std::set<unsigned int> rsids_type;    //!< typedef something inside the interface class.
    virtual const rsids_type& GetRsids() = 0;
}
struct-IRsids
{
typedef std::在接口类中设置rsids_type;//!
该语言允许使用
typedef
不必要地污染全局命名空间,但惯例显然不鼓励这样做

这里的名称空间(除其他外)是为了避免名称冲突,所以将typedef放在名称空间和/或类中(作为第二个示例)

typedef
通常进入头文件,通常用作封装的手段(将复杂类型隐藏在简单名称后面),例如:


为什么不在头文件中声明一个新的名称空间并将typedef放在那里呢?
typedef std::vector<std::vector<double>> Matrix
using Matrix = std::vector<std::vector<double>>;