【发布时间】:2017-12-01 12:50:03
【问题描述】:
在我的基本 c++ 书中,没有像下面这样的类声明。 对我来说奇怪的代码是......
boost::signals2::signal<bool (const std::string& message,
const std::string& caption, unsigned int style),
boost::signals2::last_value<bool> > ThreadSafeMessageBox;
圆括号(const std:::string...)中的东西不是类型名而是实例。怎么可能?上面的代码编译得很好。
附言模板类(signal)代码是
template<typename Signature,
typename Combiner = optional_last_value<typename boost::function_traits<Signature>::result_type>,
typename Group = int,
typename GroupCompare = std::less<Group>,
typename SlotFunction = function<Signature>,
typename ExtendedSlotFunction = typename detail::extended_signature<function_traits<Signature>::arity, Signature>::function_type,
typename Mutex = mutex >
class signal: public detail::signalN<function_traits<Signature>::arity,
Signature, Combiner, Group, GroupCompare, SlotFunction, ExtendedSlotFunction, Mutex>::type
{ /*...*};
【问题讨论】:
-
使用
**突出显示C++ 代码的一部分不是一个好主意。 -
是函数类型
标签: c++ templates parentheses boost-signals2