小编was*_*ful的帖子

label元素的for属性必须引用非隐藏的表单控件

我的代码中有一些错误这是我的错误:

label元素的for属性必须引用非隐藏的表单控件.

和myd代码:

<form action="/search">
  <span class="input input--hoshi search-wrapp main-page-open" style="display:block">
    <input class="input__field input__field--hoshi" type="text" id="search" name="keyword" placeholder="Search..."/>
    <label class="input__label input__label--hoshi input__label--hoshi-color-2" for="input-5">
      <!--<span class="input__label-content input__label-content-hoshi">Search...</span>-->
    </label>
    <span class="icon-serch"></span>
  </span>
  <input id="search-btn" type="submit" style="display: none;"/>
</form>
Run Code Online (Sandbox Code Playgroud)

这有什么问题?谢谢!

html validation

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

如何解决mac中的qt5(找不到包)cmake错误?

在使用CMake构建文件期间出现以下错误:

CMake Warning at CMakeLists.txt:33 (FIND_PACKAGE):

By not providing "FindQt5Core.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Qt5Core", but
  CMake did not find one.

  Could not find a package configuration file provided by "Qt5Core" with any of the following names:

    Qt5CoreConfig.cmake
    qt5core-config.cmake
Run Code Online (Sandbox Code Playgroud)

谁知道怎么解决这个问题?提前致谢

c++ macos qt cmake qt5

4
推荐指数
3
解决办法
9524
查看次数

如何循环遍历Jekyll的_data文件夹中的所有文件?

如何循环遍历 Jekyll 中 _data 文件夹中的每个文件?

目前,我在名为 sidebarlist.yml 的文件中有一个文件列表,如下所示:

- file1
- file2
- file3
Run Code Online (Sandbox Code Playgroud)

为了循环遍历所有这些文件,我使用以下代码:

{% for sidebar in site.data.sidebarlist %}
{% for entry in site.data.sidebars[sidebar].entries %}
...
{% endfor %}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

我想避免使用 sidebarlist.yml 并自动迭代 _data 中的所有文件。我可以这样做吗?

liquid jekyll

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

有没有办法将对象的字段隐式传递给C++中的函数

假设我有一个对象

class Obj {
public:
    int a;
    int b;
    int c;
}
Run Code Online (Sandbox Code Playgroud)

和一系列对象

Obj o[N];
Run Code Online (Sandbox Code Playgroud)

我想将每个Obj.a复制到一个int数组中,我知道其他语言允许我在C++中创建一个看起来像这样的函数

int & fun(Obj os[], T key, int N){
    int a[N];
    for (int i=0; i<N; i++) {
       a[i] = os[i].key;
    }
    return a;
}
Run Code Online (Sandbox Code Playgroud)

在C++中有没有可重复使用的方法?作为参考,Obj的代码不能被修改.

c++ function c++11

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

CMake动态链接`/ usr / local / lib`中的`.a`文件

我想针对另一个静态库对程序进行静态编译,对于本示例,我正在使用zeromq。这是我的CMakeLists.txt

cmake_minimum_required(VERSION 2.6)
add_executable( test test.cpp )
find_library(ZMQ NAMES libzmq.a)
message(STATUS ${ZMQ})
target_link_libraries( test ${ZMQ} )
Run Code Online (Sandbox Code Playgroud)

.a我运行时会找到文件mkdir build && cd build && cmake ..

-- /usr/local/lib/libzmq.a
Run Code Online (Sandbox Code Playgroud)

但是,如果我检查link.txt文件,该库是动态链接的:

/usr/bin/c++ CMakeFiles/test.dir/test.cpp.o \
    -o test -rdynamic /usr/local/lib/libzmq.a
Run Code Online (Sandbox Code Playgroud)

奇怪的是,如果我将文件移动到另一个目录,说/usr/lib再运行cmake ..一次,它将找到该库的新路径:

-- /usr/lib/libzmq.a
Run Code Online (Sandbox Code Playgroud)

但是现在它神奇地变成了静态链接:

/usr/bin/c++ CMakeFiles/test.dir/test.cpp.o \
    -o test -rdynamic -Wl,-Bstatic -lzmq -Wl,-Bdynamic
Run Code Online (Sandbox Code Playgroud)

同样的事情也适用于我链接到的其他库。

为什么我所有的库都/usr/local/lib被动态链接?

c++ cmake

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

SFINAE确定类型是否具有可能过载的方法

我正在寻找一个SFINAE解决方案,以便在编译时检查类型是否有方法.我的目标是检查类型是否是有效的"鸭子类型",但我想static_assert用来提供信息性消息,而不是无用的编译错误.

我发现[这个问题],它为我的问题提供了一个相当不错的答案,除了它在类型为方法提供重载时失败:

template<typename...> // parameter pack here
using void_t = void;

template<typename T, typename = void>
struct has_xxx : std::false_type {};

template<typename T>
struct has_xxx<T, void_t<decltype(&T::xxx)>> :
  std::is_member_function_pointer<decltype(&T::xxx)>{};
Run Code Online (Sandbox Code Playgroud)

这适用于以下示例,并区分方法和成员变量:

struct Foo { int xxx() {return 0;}; };
struct Foo2 {};
struct Foo3{ static double xxx;};
double Foo3::xxx = 42;

int main() {
   static_assert(has_xxx<Foo>::value, "");
   static_assert(!has_xxx<Foo2>::value, "");
   static_assert(!has_xxx<Foo3>::value, "");
}
Run Code Online (Sandbox Code Playgroud)

原创现场演示

如果出现过载,代码将失败:

struct Foo { int xxx() {return 0;}  void xxx(int){} };

int main() {
   static_assert(has_xxx<Foo>::value, ""); …
Run Code Online (Sandbox Code Playgroud)

c++ template-meta-programming c++11 c++14

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

在函数声明中演绎shared_ptr T.

我想写一个看起来像这样的函数:

template<class T>
void Foo(const std::shared_ptr<const T>& ptr);
Run Code Online (Sandbox Code Playgroud)

所以我可以这样称呼它:

std::shared_ptr<int> ptr;
Foo(ptr);
Run Code Online (Sandbox Code Playgroud)

但是,编译器无法推断T,我必须明确它:

Foo<int>(ptr);
Run Code Online (Sandbox Code Playgroud)

或者用它重载void Foo(const std::shared_ptr<T>& ptr).

我可以有一个单一的声明Foo,const T以便T可以推断出来吗?

c++ templates shared-ptr c++11

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

为什么我必须将地址转换为整数以使其可分配?

指针在堆上或堆栈上存储地址.经过一番搜索,我试图了解什么是"地址"; 我发现它只是一个映射内存区域的整数值.

  • 我想知道:只要一个地址只是一个整数,为什么我不能将它分配给一个整数变量:

    #include <iostream>
    using std::cout;
    using std::endl;
    
    int main()
    {
        int  a    = 1024;
        int* ptrA = &a;
    
        cout << "ptrA: " << ptrA << endl;   //  0018FF44
        cout << "*ptrA: " << *ptrA << endl; //  1024
        cout << "&a: " << &a << endl;       //  0018FF44
        cout << "a: " << a << endl;         //  1024
    
    //  int b = ptrA;      // why this is incorrect
        int b = (int)ptrA; // why I need this?
    
        cout …
    Run Code Online (Sandbox Code Playgroud)

c++ pointers

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

停止 Qt 转换动态属性

我正在使用 Qt 5.6.0。

我有一个ui在语言更改时重新翻译的表格。在 Creator 和设计器部分中,我添加了一个带有 string 的动态属性"style"

此动态属性负责为pushButton. 问题是,当我更改语言时,我的动态属性和关联的样式表不起作用。

我还发现该函数retranslateUi()是在语言更改时执行的,其中包含以下语句:

pushButton->setProperty(
    "style",
    QVariant(
        QApplication::translate("MainWindow", "button", 0)
    )
);
Run Code Online (Sandbox Code Playgroud)

问题是我能做什么来阻止 Qt 放入QApplication::translate()生成的ui_classname.h文件中。

或者,如果这QApplication::translate()不是原因,那么我该如何解决问题?

c++ user-interface qt

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

如何从 Jekyll frontmatter 中的帖子中找到值的总和

在我的每一篇 Jekyll 帖子中,我都在前面列出了一个数字:

---
minutes: X
---
Run Code Online (Sandbox Code Playgroud)

该值始终与 post-to-post 不同,我想找到所有帖子的总和。

不确定这是否可能或应该采用什么方法。

提前感谢您的任何帮助!

jekyll github-pages

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