我想知道在从MacPorts安装Qt5时是否有人也有类似的"问题".
我昨天(在Yosemite上)安装了一个frech MacPorts发行版并安装了端口qt5-mac和qt5-creator-mac.首先,我注意到(与我以前的经验相比),/Applications/MacPorts文件夹中不再有Qt Creator的链接.此外,像工具qmake不再在路径(即有对文件没有链接来自/opt/local/libexec/qt5-mac/bin于/opt/local/bin).当然,这不是一个严重的问题; 我只是想知道这是入侵行为还是可能的错误.
我有以下(非常简化)"容器"类:
class container
{
public:
template<typename T> container(const boost::shared_ptr<T> &rhs)
: m_content(rhs) { }
template<typename T>
operator T const & () const
{
return get<T>();
}
template<typename T>
T const & get() const
{
return *boost::any_cast< boost::shared_ptr<T> >(m_content);
}
private:
boost::any m_content;
};
Run Code Online (Sandbox Code Playgroud)
它应该boost::any以共享指针的形式将对象存储在容器中.如果我boost::shared_ptr<some_type>在容器中存储一些类型的对象,我想const some_type&通过用户定义的转换来获取reference(),这将允许执行以下操作:
boost::shared_ptr<some_type> x(new some_type);
container cx = x;
...
// user-defined conversion
const some_type &y = cx;
// a template conversion using a "getter"
const some_type &y = cx.get<some_type>();
Run Code Online (Sandbox Code Playgroud)
有时,我需要存储从某种抽象类型派生的对象,并对这种抽象类型的引用进行相同类型的转换,例如,像这样: …