小编sak*_*kra的帖子

测试std :: common_type是否存在

我想编写一个帮助器模板,检查模板参数包是否具有公共类型,即,如果应用于std::common_type包定义了类型.

使用std :: void_t和SFINAE我得出以下定义:

template<typename... Types, typename Enable = void>
struct has_common_type : std::false_type
{ };

template<typename... Types>
struct has_common_type<Types..., std::void_t<std::common_type<Types...>::type>> : std::true_type
{ };
Run Code Online (Sandbox Code Playgroud)

但这不起作用,因为模板参数包必须是最后一个参数.编译器引发以下错误:

error: template parameter pack must be the last template parameter
                        template<typename... Types, typename Enable = void>
Run Code Online (Sandbox Code Playgroud)

如何定义这样的模板呢?

c++ templates variadic-templates

5
推荐指数
1
解决办法
281
查看次数

如何使用Applescript应用程序包作为os x中的默认浏览器?

我的目标是使一个osx机器上点击的链接加载到启用了Apple事件的远程计算机上的safari中.为此,我正在尝试创建一个applescript应用程序,然后我在系统上创建默认浏览器.

我的Applecript看起来像这样:

on run argv
    set theurl to item 1 of argv
    set dest to "eppc://user:password@ipaddress"
    tell application "Safari" of machine dest
        activate
        open location theurl
    end tell
end run
Run Code Online (Sandbox Code Playgroud)

如果argv不是用于捕获url的合适方法,我将脚本简化为:

tell application "Safari"
    activate
    open location "http://www.google.com"
end tell
Run Code Online (Sandbox Code Playgroud)

然后我将其保存为应用程序,并告诉Safari该应用程序应该是默认浏览器,但是当我单击应用程序中的链接时,它完全忽略了我的AppleScript并在Safari中加载了url(不是我指定的url,我点击的网址).

为什么是这样 ?我是否需要为我的Applescript做一些特殊的操作才能充当浏览器?如果我通过双击它来运行我的AppleScript应用程序,它会完全按照它应该执行的操作,但如果我通过"默认浏览器"功能启动它,它根本不会运行,而是Safari接管.

如果有一些简单的事情,我做错了或不做,或者如果我完全错误的方式,请告诉我.

macos applescript

4
推荐指数
1
解决办法
1644
查看次数

如何将 NSIS 的 RequestExecutionLevel 选项添加到 CMakeLists.txt

我正在尝试在 Windows 7 上使用 NSIS 编译安装程序以在没有管理员权限的情况下工作。项目用CMake搭建,用VC2010编译。我发现我必须使用

RequestExecutionLevel user
Run Code Online (Sandbox Code Playgroud)

选项。我的问题是:我必须在 CMakeLists.txt 中放入什么才能将此选项传递给 NSIS?我发现

set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "RequestExecutionLevel user")
Run Code Online (Sandbox Code Playgroud)

在 google 上的某个地方,但是会出现错误,说无法在此部分中设置此选项。

任何帮助是极大的赞赏

nsis cmake windows-7 cpack

3
推荐指数
1
解决办法
2637
查看次数

在Eclipse 3.8中安装Subclipse 1.8

我试图在OS X 10.8.3下的Eclipse Classic 3.8.2(M20130131-0800)下安装Sublclipse 1.8.这会导致错误消息:

An error occurred while collecting items to be installed
session context was:(profile=SDKProfile, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).
No repository found containing: osgi.bundle,org.eclipse.draw2d,3.9.0.201212170307
No repository found containing: osgi.bundle,org.eclipse.gef,3.9.0.201212170307
Run Code Online (Sandbox Code Playgroud)

我怎样才能获得丢失的插件?

我已经将http://subclipse.tigris.org/update_1.8.x设置为更新站点,根据Subclipse页面,它与Eclipse 3.8兼容.在安装对话框中,我选择了"Subclipse"和"SVNKit"组中的所有可用插件.

从更新站点http://download.eclipse.org/releases/juno安装GEF 也不起作用:

An error occurred while collecting items to be installed
session context was:(profile=SDKProfile, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).
No repository found containing: osgi.bundle,org.eclipse.draw2d,3.9.0.201212170307
No repository found containing: osgi.bundle,org.eclipse.draw2d.doc.isv,3.8.1.201212170307
No repository found containing: org.eclipse.update.feature,org.eclipse.draw2d,3.9.0.201212170307
No repository found containing: org.eclipse.update.feature,org.eclipse.draw2d.sdk,3.9.0.201212170307
No repository found …
Run Code Online (Sandbox Code Playgroud)

eclipse subclipse

2
推荐指数
1
解决办法
7922
查看次数

与Hibernate一起提交事务时出现ConcurrentModificationException

在我们的应用程序中,我们已经从Hibernate 3.5.6-final升级到4.2.21.Final,现在我们得到ConcurrentModificationException一个数据库事务提交时:

java.util.ConcurrentModificationException: null
    at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901)
    at java.util.ArrayList$Itr.next(ArrayList.java:851)
    at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:386)
    at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:304)
    at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:349)
    at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:56)
    at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1195)
    at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:404)
    at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
    at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:175)
Run Code Online (Sandbox Code Playgroud)

这是Hibernate 4.2的已知问题吗?

java hibernate

2
推荐指数
1
解决办法
3448
查看次数

用过滤器提升日志记录

我是boost-log的新手,并尝试使用过滤器示例使用boost-log 1.1 进行简单的日志记录.代码如下所示:

#include <boost/log/core.hpp>
#include <boost/log/trivial.hpp>
#include <boost/log/filters.hpp>

void init()
{
    logging::core::get()->set_filter
    (
     filters::attr< logging::trivial::severity_level >("Severity") >= logging::trivial::info
     );
}

int main(int, char*[])
{
    BOOST_LOG_TRIVIAL(trace) << "A trace severity message";
}
Run Code Online (Sandbox Code Playgroud)

使用clang进行编译会产生以下错误消息:

/Users/admin/Documents/cmake tests/boost-log/main.cpp:7:5: error: use of undeclared identifier 'logging'
    logging::core::get()->set_filter
    ^
/Users/admin/Documents/cmake tests/boost-log/main.cpp:9:3: error: use of undeclared identifier 'filters'; did you mean 'boost::log_mt_posix::filters'?
         filters::attr< logging::trivial::severity_level >("Severity") >= logging::trivial::info
         ^~~~~~~
         boost::log_mt_posix::filters
/usr/local/include/boost/log/filters/has_attr.hpp:32:11: note: 'boost::log_mt_posix::filters' declared here
namespace filters {
          ^
/Users/admin/Documents/cmake tests/boost-log/main.cpp:9:18: error: …
Run Code Online (Sandbox Code Playgroud)

c++ boost boost-log

0
推荐指数
1
解决办法
1496
查看次数