小编cjh*_*cjh的帖子

doxygen一次注释多个变量

如果我有以下内容:

/**
 * @brief (x,y,z) points for block
 */
int x, y, z;
Run Code Online (Sandbox Code Playgroud)

它只会生成x的文档,是否可以在doxygen中使用一条注释对所有x,y和z进行注释?

编辑按照envu的建议,我现在有以下内容(基于http://www.doxygen.nl/manual/grouping.html#memgroup)

//@{
/** some documentation here */
int x, y, z;
//@}
Run Code Online (Sandbox Code Playgroud)

要么

//@{
/**
 * @brief some documentation here
 */
int x, y, z;
//@}
Run Code Online (Sandbox Code Playgroud)

然而,这两个仍然只记录x.尝试使用不同的表单我还没有得到相同的文档字符串来跨越多个变量

c c++ variables comments doxygen

14
推荐指数
3
解决办法
9216
查看次数

模板工具包IF在空数组上返回true,我可以将其设为false吗?

所以,如果我给模板工具包一个引用数组作为参数

ARRAY_REF => \@array
Run Code Online (Sandbox Code Playgroud)

然后在模板中包含以下代码

[% IF ( ARRAY_REF ) %]
  Do something
[% ELSE %]
  Do something else
[% END %]
Run Code Online (Sandbox Code Playgroud)

其他情况永远不会被触发.

用.替换参数代码

ARRAY_REF => @array ? \@array : undef;
Run Code Online (Sandbox Code Playgroud)

似乎解决了这个问题,但我想知道是否有一种方法可以让模板工具包评估一个空数组(通过引用传递)为false,因为我的项目中有很多实例,我相信这个实例正在被使用(如在HTML模板中)亲它按预期工作).

提前谢谢大家的帮助.

perl template-toolkit

8
推荐指数
2
解决办法
6507
查看次数

模板工具包字符编码

似乎模板工具包没有正确处理编码.

我传递template->process一个文件名(在哪里获取模板),一个哈希引用(包含所有参数)和一个标量引用(在哪里放置输出)然后我返回它,然后将其显示给用户.

当我给它一个带有变音符号的字符串时,html输出包括一个黑色菱形,带有白色问号代替每个字母(但字母数正确).任何其他角色都很好.

我在调用模板 - >进程之前使用warn打印出字符串,此时它很好,从我可以告诉它在template->process调用期间事情变成垃圾.

有任何想法吗?我尝试过使用ENCODING => "utf8",binmode => ":utf8"但对输出没有任何影响.

这是我的代码,其中一些胖子被修剪出来只是为了显示我对模板 - >过程的调用,注意如果我遗漏{binmode => 'utf8'}它就没有效果了.

<put variables in hash referenced to by vars>
<print out variables in has referenced to by $var>
my $data;
$template->process( $self->filename, $vars, \$data, {binmode => ':utf8'}) || die "Template process failed: ", $template->error();
return $data;
Run Code Online (Sandbox Code Playgroud)

求助了 嘿所有感谢您的回答,问题结果是模板进程完成,我们在输出之前将字符串写入临时文件,因此我们还需要为文件设置binmode,代码现在看起来喜欢:

<put variables in hash referenced to by vars>
<print out variables in has …
Run Code Online (Sandbox Code Playgroud)

apache perl template-toolkit

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

c ++模板特化方法定义

以下代码工作正常,一个带有定义和用法的简单模板类

#include <string>
#include <iostream>
using namespace std;

template<class T> class foo{
  public:
  string what();
};

template<class T> string foo<T>::what(){
  return "foo of type T";
}

int main(){
  foo<int> f;
  cout << f.what() << endl;
}
Run Code Online (Sandbox Code Playgroud)

如果我然后添加以下内容(上面的主要,但在声明模板类foo之后;)

template<> class foo<char>{
public:
  string what();
};
template<> string foo<char>::what(){
  return "foo of type char";
}
Run Code Online (Sandbox Code Playgroud)

我从g ++收到错误

第19行:错误:模板ID'什么<>'为'std :: string foo :: what()'与任何模板声明都不匹配

这是一个显示错误的键盘:http://codepad.org/4HVBn9oJ

我做了什么明显的错误?或者使用c ++模板是不可能的?是否可以定义所有内联方法(使用模板<> foo的定义)?

再次感谢所有人.

c++ templates specialization

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

析构函数似乎被称为'早期'

原来这是一个简单的构造函数错误使用问题. 有关更新的信息,请参阅"编辑"部分.

很抱歉还有另一个C++ dtor问题...但是我似乎无法找到一个与我一样的,因为所有其他人都分配给STL容器(这将删除对象本身)而我的是一个指针数组.

所以我有以下代码片段

#include<iostream>

class Block{
public:
    int x, y, z;
    int type;
    Block(){
        x=1;
        y=2;
        z=3;
        type=-1;
    }
};

template <class T> class Octree{
    T* children[8];
public:
    ~Octree(){
        for( int i=0; i<8; i++){
            std::cout << "del:" << i << std::endl;
            delete children[i];
        }
    }    
    Octree(){
        for( int i=0; i<8; i++ )
            children[i] = new T;
    }
    // place newchild in array at [i]
    void set_child(int i, T* newchild){
        children[i] = newchild;
    }
    // return child at [i] …
Run Code Online (Sandbox Code Playgroud)

c++ memory destructor dynamic

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