小编yon*_*tix的帖子

除了noexcept之外的C++ ISO noexcept

C++标准中,有以下定义:

template <class T, size_t N> void swap(T (&a)[N], T (&b)[N])
      noexcept(noexcept(swap(*a, *b)));
Run Code Online (Sandbox Code Playgroud)

怎么noexcept(noexcept(swap(*a, *b)))办?

c++ noexcept

29
推荐指数
1
解决办法
1553
查看次数

统一c - > a - > b和(a - > b) - > c

什么是统一的类型时,由Haskell的类型推断合成器的类型c -> a -> b(a -> b) -> c

有人可以解释我如何解决它?

谢谢!

haskell types

12
推荐指数
3
解决办法
323
查看次数

启用复制粘贴时无法连接到VirtualBox内核服务

我尝试在Oracle Virtual Box中启用复制粘贴功能.为了实现这一目标,我运行:

sudo /usr/bin/VBoxClient --clipboard
Run Code Online (Sandbox Code Playgroud)

我明白了

Failed to connect to the VirtualBox kernel service
Run Code Online (Sandbox Code Playgroud)

这是什么意思,我该如何解决?我尝试用sudo启动Virtual Box,但它没有用.我提到,我virtualbox-guest-utilsvirtualbox-guest-x11安装.Ubuntu 14.04

谢谢!

ubuntu virtualbox copy-paste virtual-machine ubuntu-14.04

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

java access通过反射访问整数构造函数

我有这个代码.为什么它不起作用?(工作意味着它显示3)我该如何解决?

public class Main {
    public static<V> V copy(V var){
        try{ 
            return (V) var.getClass().getConstructor(var.getClass()).newInstance(var);
        }
        catch(Exception e){
            System.out.println("Copy faield " + e.getMessage() + " ");
            e.printStackTrace();
        }
        return null;
    }

    public static void main(String[] args) {
        Integer a = new Integer(3);
        Integer b = copy(a);

        System.out.println(a);
        System.out.println(b);


    }
}
Run Code Online (Sandbox Code Playgroud)

这是输出:

 Copy faield java.lang.Integer.<init>(java.lang.Integer) 
    java.lang.NoSuchMethodException: java.lang.Integer.<init>(java.lang.Integer)
        at java.lang.Class.getConstructor0(Class.java:2818)
        at java.lang.Class.getConstructor(Class.java:1723)
        at Main.copy(Main.java:7)
        at Main.main(Main.java:19)
    3
    null
Run Code Online (Sandbox Code Playgroud)

谢谢!

java

8
推荐指数
1
解决办法
2353
查看次数

Qt项目中的unique_ptr

我有一个简单的Qt项目.我include <memory>但是std :: unique_ptr不可用.我知道我应该使用Qt特定的智能指针,但我需要包含一个包含std :: unique_ptr的更大的项目.

我能做什么?

谢谢!

c++ qt unique-ptr

7
推荐指数
1
解决办法
2787
查看次数

仅当提供了模板参数时,如何才能启用类模板成员函数?

是否可以有一个带有可选模板参数的类,可以像这样调用?:

#include <iostream>

template <typename T = void>
class A final
{
public:
    // This class can be called only when T exists.
    void f()
    {
        printf("%d\n", member);
    }

    // This method can be called only when T is missing.
    void g()
    {
        printf("No template parameter\n");
    }
public:
    T member;
};

int main()
{

    A<int> a1;
    A a2;
    a1.f(); // should be valid
    a1.g(); // should be invalid, cannot compile
    a2.f(); // should be invalid, cannot compile
    a2.g(); // should …
Run Code Online (Sandbox Code Playgroud)

c++ templates member-functions c++-concepts c++20

6
推荐指数
2
解决办法
194
查看次数

Graphviz 点集纵横比(16:9、4:3 等)

有没有办法设置点图的纵横比?我试图获得包含图形并具有特定纵横比的最小矩形。

我一直在寻找这个答案很多,我找不到任何相关的东西。

graph dot graphviz

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

Java抽象类,抽象的构造函数

我试图找到一种方法来强制实现接口的用户,或者扩展一个类来创建几个构造函数.我认为这样做的一种方法是在抽象类中创建一个抽象构造函数,但我发现我不能这样做.

我该如何解决这个问题?是否有一些方法强制用户创建特定的构造函数?

谢谢!

java

4
推荐指数
2
解决办法
2679
查看次数

Bash查找行号

我有这个脚本:

find . -name "$2" -print | xargs grep --colour=auto "$1"
Run Code Online (Sandbox Code Playgroud)

它在$ 2匹配文件中搜索$ 1字.如何打印已找到该单词的行号.

谢谢

linux bash

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

无法安装Cabal-1.20.0.2

当我尝试安装Cabal-1.20.0.2时出现此错误:

$ cabal install Cabal-1.20.0.2.tar.gz 
Resolving dependencies...
Configuring Cabal-1.20.0.2...
Failed to install Cabal-1.20.0.2
Last 10 lines of the build log ( /home/yonutix/.cabal/logs/Cabal-1.20.0.2.log ):
cabal: Error: some packages failed to install:
Cabal-1.20.0.2 failed during the configure step. The exception was:
user error (
/tmp/Cabal-1.20.0.2-11804/Cabal-1.20.0.2/Distribution/Simple/Utils.hs:386:31:
Warning:
In the use of ‘runGenProcess_’
(imported from System.Process.Internals):
Deprecated: "Please do not use this anymore, use the ordinary
'System.Process.createProcess'. If you need the SIGINT handling, use
delegate_ctlc = True (runGenProcess_ is now just an imperfectly emulated …
Run Code Online (Sandbox Code Playgroud)

haskell ghci cabal

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