小编bar*_*rej的帖子

Sublime Text - 在搜索中排除评论

每次我在数百个文件中搜索一个函数时,我在注释中看到很多匹配没有代码效果的匹配.

有人可以将Sublime Text的搜索范围限制为实际代码,并排除注释吗?

我使用Sublime Text 3开发C++程序.

comments sublimetext sublimetext2 sublimetext3

14
推荐指数
2
解决办法
1442
查看次数

通过预定点的 SVG 曲线

我是 SVG 的初学者。

我需要一条穿过点列表的 SVG 曲线。它是一个用 C++ 计算的数学函数,输出结果应该写入 SVG 文件中。我的问题是pathSVG 中的标签没有穿过所有点。相反,它会在中间跳过其中一些,而只是倾向于它们。SVG是否有任何设施可以使曲线通过整个点并以自动方式适当弯曲曲线?

数学曲线

<svg height="400" width="450">
  <path d="M 80 90 C 190 40, 300 60, 380 160" stroke="blue" stroke-width="5" fill="none" />
  <path d="M 80 90 L 190 40, 300 60, 380 160" stroke="green" stroke-width="1" fill="none"/>
  <g stroke="black" stroke-width="3" fill="black">
    <circle id="pointC" cx="80" cy="90" r="3" stroke="black"/>
    <circle id="pointA" cx="190" cy="40" r="3" stroke="green"/>
    <circle id="pointC" cx="300" cy="60" r="3" stroke="red"/>
    <circle id="pointB" cx="380" cy="160" r="3" stroke="blue"/>
  </g>
  Sorry, your browser does not support …
Run Code Online (Sandbox Code Playgroud)

math svg curve-fitting

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

模板检测T是指针还是类

考虑以下代码:

class MyClass
{
    ...
};

template <typename Object>
class List
{
public:

    void insert(const Object & x)
    {
        // call when Object is MyClass
    }

    void insert(const Object & x)
    {
        // call when Object is MyClass*
    }
}

int main()
{
    MyClass a;

    List<MyClass> lst;
    List<MyClass*> plst;

    lst.insert(a);
    plst.insert(new Myclass);

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

如何根据模板是类还是指针来告诉编译器调用不同的方法?

如何修复上面的代码?

c++ templates segmentation-fault sfinae

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

强制编译器显示变量的类型

我正在编制一个我面临的相当大的项目

错误:'CRoom room'重新声明为不同类型的符号

对了

class CRoom
{
.....
} room("test");
Run Code Online (Sandbox Code Playgroud)

问题是我搜索了整个项目文件,我在其他地方找不到这样的变量.是否有可能强迫编制者告诉我它在哪里找到了这种定义的原始位置?如果不可能,至少可以在comfile时间显示原始变量的类型(注意,这个程序有很多其他错误,我不能运行它并显示变量类型.我希望编译器显示类型为了我).

c++ compiler-errors compilation c++11

5
推荐指数
2
解决办法
400
查看次数

使用boost :: wave时运行时错误消息

我收到以下运行时错误消息

terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::wave::cpplexer::lexing_exception> >'
  what():  boost::wave::lexing_exception
Run Code Online (Sandbox Code Playgroud)

当我尝试运行以下代码时:

#include <vector>
#include <algorithm>
#include <boost/wave.hpp>
#include <boost/wave/cpplexer/cpp_lex_token.hpp>
#include <boost/wave/cpplexer/cpp_lex_iterator.hpp>

std::string strip_comments(std::string const& input)
{
    std::string output;
    typedef boost::wave::cpplexer::lex_token<> token_type;
    typedef boost::wave::cpplexer::lex_iterator<token_type> lexer_type;
    typedef token_type::position_type position_type;

    position_type pos;

    lexer_type it = lexer_type(input.begin(), input.end(), pos, 
        boost::wave::language_support(
            boost::wave::support_cpp|boost::wave::support_option_long_long));
    lexer_type end = lexer_type();

    for (;it != end; ++it)
    {
        if (*it != boost::wave::T_CCOMMENT
         && *it != boost::wave::T_CPPCOMMENT)
        {
            output += std::string(it->get_value().begin(), it->get_value().end());
        }
    }
    return output;
}

int main()
{ …
Run Code Online (Sandbox Code Playgroud)

c++ regex gcc boost c++11

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

将类模板推迟到其构造函数

我担心我所寻找的是不可能的.它可能需要改变我的设计.我正在寻找将类模板推迟到其构造函数.这是一个例子:

以下代码没有问题:

#include <iostream>
using namespace std;

template<class T1,class T2>
T1 product(T1 t1,T2 t2)
{
    return (T1)(t1*t2);
}

int main()
{
    double t1=5.5;
    int t2=4;
    cout<<t1<<" x "<<t2<<" = "<<product(t1,t2)<<endl;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

现在,如果我想将函数包装product在一个类中:

#include <iostream>
using namespace std;

template<class T1,class T2>
class A
{
public:
    T1 num1;
    T2 num2;

    template<class T1,class T2>
    A(T1 t1,T2 t2)
    {
        num1=t1;
        num2=t2;
    }

    T1 product()
    {
        return (T1)(num1*num2);
    }

    T1 division()
    {
        return (T1)(num1/num2);
    }   
};

int main()
{
    double t1=5.5; …
Run Code Online (Sandbox Code Playgroud)

c++ templates c++11

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

装配:MOV 或 DEC 会影响零标志吗?

在反汇编代码中:

movsx eax,[address1]
# a few fpu computations
dec eax
# so many fpu computations
jz label2
Run Code Online (Sandbox Code Playgroud)

如果 fpu 计算不影响零标志,那么我们可以假设它等于:

# a few fpu computations
# so many fpu computations
movsx eax,[address1]
dec eax
jz label2
Run Code Online (Sandbox Code Playgroud)

然后,我的问题是,你mov或者dec对零标志是否有影响?

x86 assembly disassembly

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

将'const CMyclass'作为'this'参数传递给...丢弃限定符[-fpermissive]

通过编译以下代码

g++ -std=c++11 test.cpp
Run Code Online (Sandbox Code Playgroud)

给我以下错误:

test.cpp: In lambda function:
test.cpp:17:128: error: passing ‘const CMyclass’ as ‘this’ argument of ‘void CMyclass::my_method(const state_type&, double)’ discards qualifiers [-fpermissive]
  std::function<void(const state_type &,const double)> observer = [=](const state_type &x,const double t){my_class.my_method(x,t);};
                                                                                                                                ^
Run Code Online (Sandbox Code Playgroud)

我搜索过其他类似的问题,但我无法弄清楚这段代码有什么问题.

#include <vector>
#include <functional>

typedef std::vector<int> state_type;

class CMyclass
{
public:
    void my_method( const state_type &x , const double t )
    {
    }
};

int main()
{
    CMyclass my_class;
    std::function<void(const state_type &,const double)> observer =
         [=](const state_type &x,const double t)
         {
             my_class.my_method(x,t); …
Run Code Online (Sandbox Code Playgroud)

c++ lambda compiler-errors function-pointers pass-by-reference

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

const_cast设置规则并将其分解为函数const

在我在网上发现的下面的例子中,提到的一个优点const_cast是它允许一个常量函数改变类成员.这是一个问题.我们为什么要设置一个函数规则const,然后用该规则来破坏该规则const_cast?这不是作弊吗?最好不设置const功能吗?

#include <iostream>
using namespace std;

class student
{
private:
    int roll;
public:

    student(int r):roll(r) {}

    // A const function that changes roll with the help of const_cast
    void fun() const
    {
        ( const_cast <student*> (this) )->roll = 5;
    }

    int getRoll()  { return roll; }
};

int main(void)
{
    student s(3);
    cout << "Old roll number: " << s.getRoll() << endl;

    s.fun();

    cout << "New roll number: " << s.getRoll() << …
Run Code Online (Sandbox Code Playgroud)

c++ const-cast c++11

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

以下汇编代码有什么作用?

我正在遵循这个编译的代码(我不知道编译器也没有源代码).

Sub1:
mov edx,[esp+04h]
and edx,00000300h
or  edx,0000007Fh
mov [esp+06h],dx
fldcw   word ptr [esp+06h]
retn
Run Code Online (Sandbox Code Playgroud)

我的理解:

Sub1(4byte param1)
edx=param1&0x00000300|0x0000007F
higher 2 bytes of param1 = lower 2 bytes of edx
fldcw ???????
Run Code Online (Sandbox Code Playgroud)

fldcw加载控制字.但是浮点的控制字是什么?

结果存储在param1的高2字节中.我对吗?

这个subroutin的目的是什么?

floating-point x86 assembly disassembly ieee-754

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