小编xsk*_*xzr的帖子

如何将我的Java程序转换为.exe文件?

如果我有一个Java源文件(*.java)或一个类文件(*.class),我该如何将其转换为.exe文件?

我还需要一个程序安装程序.

java installer exe

488
推荐指数
13
解决办法
41万
查看次数

"STL"和"C++标准库"之间有什么区别?

有人把这篇文章给我的注意,声称(我意译)的STL长期被误指整个C++标准库,而不是从SGI STL中采取的部分.

(...)它指的是"STL",尽管很少有人仍然使用STL(在SGI设计).

C++标准库的一部分基于STL的一部分,正是这些部分,许多人(包括几位作者和臭名昭着的错误记录的cplusplus.com)仍然称为"STL".但是,这是不准确的; 事实上,C++标准从未提及"STL",两者之间存在内容差异.

(...)"STL"很少用于指代恰好基于SGI STL的stdlib的位.人们认为这是整个标准库.它被放在简历上.这是误导.

我几乎不了解C++的历史,所以我不能判断文章的正确性.我应该避免使用术语STL吗?或者这是一个孤立的意见?

c++ stl std c++-faq c++-standard-library

432
推荐指数
5
解决办法
9万
查看次数

Windows上有没有类似inotify的东西?

在Linux OS中,有一个ionotify子系统,它通知应用程序对文件系统的更改.

但是,我主要是一个Windows用户,所以我想知道是否有类似的方法来监控文件系统的变化?

windows inotify

92
推荐指数
5
解决办法
4万
查看次数

使用STL容器进行中值计算时,正确的方法是什么?

假设我需要从1000000个随机数值序列中检索中值.

如果使用任何但是 STL ::名单,我没有(内置)的排序方式为中值计算序列.

如果使用STL :: list,我不能随机访问值来检索排序序列的中间(中位数).

是自己实现排序和使用例如STL :: vector更好,还是使用STL :: list并使用STL :: list :: iterator for-loop-walk到中值?后者似乎不那么开销,但也感觉更难看..

或者我有更多更好的选择吗?

c++ algorithm containers stl median

40
推荐指数
5
解决办法
3万
查看次数

使用透明的std函数对象时,我们还需要编写空的尖括号吗?

使用类模板参数推导我们可以写:

std::less Fn;
Run Code Online (Sandbox Code Playgroud)

但是,G ++ 8.2拒绝此代码:

#include <algorithm>
#include <vector>
#include <functional>

int main()
{
std::vector v= { 1, 3, 2, 7, 5, 4 };

std::sort(v.begin(),v.end(),std::greater());
}
Run Code Online (Sandbox Code Playgroud)

发出以下错误:

error: cannot deduce template arguments for 'greater' from ()
Run Code Online (Sandbox Code Playgroud)

Clang ++ 7.0和MSVC 15.8.0在没有警告的情况下编译它.哪个编译器是对的?

c++ templates language-lawyer argument-deduction c++17

34
推荐指数
2
解决办法
1790
查看次数

在Java中将字符串从snake case转换为camel case

如何在Java中将蛇案转换为驼峰案?

输入:"input_in_snake_case"

输出:"InputInSnakeCase"

java string

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

lambda 函数从全局变量的引用中可变捕获的行为差异

我发现如果我使用 lambda 来捕获对具有 mutable 关键字的全局变量的引用,然后修改 lambda 函数中的值,则结果在编译器之间是不同的。

#include <stdio.h>
#include <functional>

int n = 100;

std::function<int()> f()
{
    int &m = n;
    return [m] () mutable -> int {
        m += 123;
        return m;
    };
}

int main()
{
    int x = n;
    int y = f()();
    int z = n;

    printf("%d %d %d\n", x, y, z);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

结果来自 VS 2015 和 GCC (g++ (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609):

100 223 100
Run Code Online (Sandbox Code Playgroud)

结果来自 clang++(clang 版本 3.8.0-2ubuntu4 (tags/RELEASE_380/final)):

100 223 …
Run Code Online (Sandbox Code Playgroud)

c++ lambda language-lawyer c++11

22
推荐指数
2
解决办法
964
查看次数

在引用初始化中使用已删除的复制构造函数复制初始化

考虑以下代码:

#include <iostream>
class Data{
public:
    Data() = default;
    Data(Data const&) = delete;
    Data(int) {

    }
};
int main(){
  int a = 0;
  const std::string& rs = "abc"; // rs refers to temporary copy-initialized from char array
  Data const& d_rf = a;          // #2 but here can be complied
  // accroding to the standard, the reference in #2 is bound to a temporary object, the temporary is copy-initialized from the expression
}
Run Code Online (Sandbox Code Playgroud)

[dcl.init.ref]

如果T1或T2是一个类类型和T1不参考相关到T2,用户定义的转换正在使用的规则考虑复制初始化型“CV1 T1”的对象的由用户定义的转换([dcl.init ], [over.match.copy], [over.match.conv]); …

c++ language-lawyer implicit-conversion c++11 reference-binding

19
推荐指数
1
解决办法
1403
查看次数

不同版本的 g++ 重载解析结果不一致

当我使用 g++ 5.4.0 时,下面的示例代码按预期工作,但在我将 g++ 更新为 10.2.0 后,结果发生了变化。我也在clang++ 11.0.1上测试了示例代码,结果和g++ 5.4.0一样。

我搜索了一些相关的问题,但没有得到有效的答案。据我所知,重载函数应该在模板之前匹配,为什么g++ 10.2.0得到不同的结果,我该如何解决?

因为原始源代码非常复杂,所以用其他c++特性重构它们并不容易,这个问题可以通过较小的改动来解决吗?

示例代码的目标是使用重载函数Base::operator const std::string&()执行一些特殊动作,使用模板函数执行常见动作。

#include <string>
#include <iostream>

class Base 
{
public:
    template <class T>
    operator const T&() const;
    virtual operator const std::string&() const;
};

template <class T>
Base::operator const T&() const
{
    std::cout << "use template method" << std::endl;
    static T tmp{};
    return tmp;
}

Base::operator const std::string&() const
{
    std::cout << "use overload method" << std::endl;
    const static std::string tmp;
    return tmp;
}

template …
Run Code Online (Sandbox Code Playgroud)

c++ templates g++ language-lawyer overload-resolution

17
推荐指数
1
解决办法
822
查看次数

如何在keras中记录每批的val_loss和loss

我在 keras 中使用回调函数来记录lossval_loss每个时代,但我想按批次做同样的事情。我找到了一个名为 的回调函数on_batch_begin(self,batch,log={}),但我不知道如何使用它。

python machine-learning neural-network keras

16
推荐指数
1
解决办法
5907
查看次数