小编mkm*_*mkm的帖子

对于boost :: ref没有匹配的调用错误,但是对于std :: ref没有

我已经写了一些代码进行计数用算符和矢量的元素的数量refbind模板从boost::std::(对于C++ 11)的命名空间.我正在使用a #define来切换boost::std::名称空间.我正在使用boost版本1.53,我的编译命令是g++ test.cpp -std=c++11.我已经尝试过使用gcc版本4.7.2和4.6.3,但两者都有相同的错误.

我有3个问题:

  1. 我不明白为例2生成的错误.
  2. 是否可以通过切换命名空间来使这样的代码成为可移植的?
  3. 是否有一个很好的参考,详细描述之间的差异stdboost版本bind,reffunction?(我看到了这个问题,但答案没有提及reffunction)

谢谢!

PS这个例子只是说明了我的问题,我知道size()std::vector:-)

//#define USE_STD

#ifdef USE_STD
#include <functional>
using namespace std::placeholders;
namespace impl = std;
#else
#include <boost/version.hpp>
#include <boost/bind.hpp>
#include <boost/ref.hpp>
namespace impl = boost;
#endif

#include <iostream>
#include <algorithm>
#include <vector>

class Item { …
Run Code Online (Sandbox Code Playgroud)

c++ boost c++11 boost-ref

6
推荐指数
1
解决办法
876
查看次数

在 C++ 项目中使用 Clang 时出现“使用未声明的标识符”错误

我在我的 C++ 项目中使用Clang作为语法检查器。它是通过 Emacs 中的 Flycheck 调用的,我收到了一个恼人的 use of undeclared identifier错误,下面的最小工作示例说明了该问题:

在文件中testnamepace.cpp

#include "testnamespace.hpp"

int main() {
    const unsigned DIM = 3;
    testnamespace::A<DIM> a;
    a.f();
    a.g();
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

在文件中testnamespace.hpp

#ifndef testnamespace_h
#define testnamespace_h

#include <iostream>

namespace testnamespace {
    // My code uses lots of templates so this MWE uses a class template
    template <unsigned DIM> class A;
}

template <unsigned DIM>
class testnamespace::A{
public:
    static const unsigned dim = DIM;

    A() {std::cout …
Run Code Online (Sandbox Code Playgroud)

c++ llvm clang undeclared-identifier flycheck

6
推荐指数
0
解决办法
7248
查看次数

Emacs ediff 标记了不同目录缓冲区中的文件

我有以下函数,它对我在 dired 缓冲区中标记的文件运行 ediff:

(defun mkm/ediff-marked-pair ()
  "Run ediff-files on a pair of files marked in dired buffer"
  (interactive)
  (let ((marked-files (dired-get-marked-files nil)))
    (if (not (= (length marked-files) 2))
    (message "mark exactly 2 files")
      (ediff-files (nth 0 marked-files)
           (nth 1 marked-files)))))
Run Code Online (Sandbox Code Playgroud)

它仅适用于同一目录中的文件,如何使其适用于我在不同目录中标记的文件?

emacs dired emacs-ediff

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