在我的基本 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
...) 中的内容不是类型名,而是实例。怎么可能?上面的代码编译得很好。
ps模板类(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
{ /*...*};