要将用户定义的数据类型传递到SystemC通道模板,需要将这些数据类型定义为实现不同类型的运算符'','=','=='的类。 我需要定义sc_fifo如:返回引用的类方法C++/SystemC
sc_fifo<route_t>
为了做到这是正确的,数据类型route_t必须被写为在下面的例子。
class route_t
{
public:
route_dir_t route_dir;
unsigned int vc_index;
// methods allowing the structure to be passed into SystemC channels
// constructor
route_t(route_dir_t _route_dir, unsigned int _vc_index) {
route_dir = _route_dir;
vc_index = _vc_index;
}
inline bool operator == (const route_t& _route) const {
return (route_dir == _route.route_dir && vc_index == _route.vc_index);
}
inline route_t& operator = (const route_t& _route) {
route_dir = _route.route_dir;
vc_index = _route.vc_index;
return *this;
}
}; // end class route_t
- 为什么SystemC的需要这样的实现?
- 为什么运算符'='需要返回对象本身的引用?它只是更新内部成员..
- 可以将数据类型定义为结构而不是内部方法实现所需的运算符?
- 为什么在此上下文中使用“内联”?
- 如何返回*这相当于在方法声明中返回对象的引用?
为什么不问赋值运算符的语义,而不是发布主要是无关紧要的东西吗?这会使问题更清楚。 – juanchopanza
不是每个人都是C++的专家,并感谢您的好评。与你无关,并不会让每个人都无关紧要。我将删除帖子,并参考发布前我试图找到的答案。 – Theo
您的大部分帖子都与您所提问题无关,这会让帖子感到困惑。 – juanchopanza