从1.8.0版开始,doxygen 支持 markdown.对于习惯的人来说org-mode,写入org-mode和导出的选择markdown可能很有吸引力.由于markdown实施与标准doxygen略有不同markdown,我想问:有没有人尝试过这个工作流程?用这种方式编写文档时应该记住什么?
我理解(这是一个来源),只要两个定义不冲突,就可以重新定义默认模板参数。因此,我尝试使用 g++ 5.3.1 编译以下内容:
\n\ntemplate <class = int> class A; // forward declaration\ntemplate <class T = A<>> struct B {};\n\ntemplate <class T = int> class A {}; // "= int" here is for clarity\n\nint main() { return 0; }\nRun Code Online (Sandbox Code Playgroud)\n\n编译器抱怨:
\n\n\n\n\n错误:重新定义 \xe2\x80\x98class T\xe2\x80\x99 的默认参数
\n
我的理解哪里不对?
\n我正在建立一个在线课程网站。当用户以全屏模式观看课程时,我想记住这一点,以便在安装react-player下一课时使用全屏模式。我希望会有一个onFullscreenMode回调,但文档没有列出任何此类内容。我怎样才能实现这个目标?
编辑1:根据@onkarruikar的回复,我尝试使用screenfull。首先,我很惊讶它没有安装,尽管real-player应该使用它进入全屏模式。安装包并导入后,出现编译错误:
.../node_modules/screenfull/index.js 11:44
Module parse failed: Unexpected token (11:44)
File was processed with these loaders:
.../node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|
| for (const methodList of methodMap) {
> const exitFullscreenMethod = methodList?.[1];
|
| if (exitFullscreenMethod in document) {
Run Code Online (Sandbox Code Playgroud)
编辑2:我也不明白为什么演示使用自定义按钮切换到全屏模式,而我看到一个按钮(
) 对播放器本身:
以下两段代码之间的唯一区别是引用的使用.我理解为什么第一个代码片段无法编译,并且正在寻求帮助以理解第二个代码编译的原因.
第一个片段:
int a[2][3] = {0,1,2,3,4,5};
for (auto row : a)
for (auto column : row)
cout << column << endl;
Run Code Online (Sandbox Code Playgroud)
上面的代码没有编译,因为'row'的类型是int的指针,而不是序列.
第二个片段:
int a[2][3] = {0,1,2,3,4,5};
for (auto &row : a)
for (auto column : row)
cout << column << endl;
Run Code Online (Sandbox Code Playgroud)
这段代码编译.如果我正确理解auto是如何工作的,'row'是对int指针的引用.但为什么这个引用可以被视为一个序列而不是常规指针?
我的Term类中定义了以下运算符重载:
public static Term operator *(int c, Term t) {...}
Run Code Online (Sandbox Code Playgroud)
该类还定义了从a Variable到的隐式转换Term:
public static implicit operator Term(Variable var) {...}
Run Code Online (Sandbox Code Playgroud)
我想了解为什么以下不编译:
static void Main(string[] args)
{
Variable var = ...; // the details don't matter
Console.WriteLine(2 * var); // var isn't implicitly converted to Term...
Console.ReadKey();
}
Run Code Online (Sandbox Code Playgroud)
编译器说:
运算符'*'不能应用于'int'和'OOSnake.Variable'类型的操作数
为什么不operator *发现我的超负荷?
编辑:根据评论中的建议,这是一个重新产生错误的小完整示例:
namespace Temp
{
class A {
}
class B
{
public static implicit operator B(A a) { return new B(); } …Run Code Online (Sandbox Code Playgroud) 我的所有类都实现了一个dump成员函数,例如:
struct A {
template <typename charT>
std::basic_ostream<charT> &
dump(std::basic_ostream<charT> &o) const {
return (o << x);
}
int x = 5;
};
Run Code Online (Sandbox Code Playgroud)
我想operator<<为所有这样的类实现一次函数:
template<typename charT, typename T>
std::basic_ostream<charT> &
operator<< (std::basic_ostream<charT> &o, const T &t) {
return t.dump(o);
}
Run Code Online (Sandbox Code Playgroud)
问题是此模板捕获了所有类型,包括标准类型.有办法解决这个问题吗?
这是我在SFINAE的第一次尝试:
#include <type_traits>
#include <iostream>
struct C1 {
using T = int;
};
struct C2 {
using T = void;
};
// For classes that declare T = int
template <class C>
void f(C &c,
std::enable_if<!std::is_same<typename C::T, void>::value, int>::type = 0) {
std::cout << "With T" << std::endl;
}
// For classes that declare T = void
template <class C>
void f(C &c,
std::enable_if<std::is_same<typename C::T, void>::value, int>::type = 0) {
std::cout << "Without T" << std::endl;
}
int main() { …Run Code Online (Sandbox Code Playgroud) 考虑以下宏:
#define CAT(X, Y) X ## Y
#define CMB(A, B) CAT(A, B)
#define SLB_LOGGING_ALGORITHM CMB(Logging, SLB_ALGORITHM)
Run Code Online (Sandbox Code Playgroud)
其中SLB_ALGORITHM是定义的预处理器符号.
如果我只是用CAT,而不是直接的CMB,SLB_ALGORITHM没有得到扩大.为什么这种情况以及间接有何帮助?
请不要介意以下最小例子的陌生感(我必须把它做得更大才能证明我为什么这样做):
文件test.cpp:
#include "a.h"
int main() {
return 0;
}
Run Code Online (Sandbox Code Playgroud)
档案啊:
namespace N { // without namespace all is well!
#include "b.h"
}
Run Code Online (Sandbox Code Playgroud)
文件bh:
/// \file
#ifndef GUARD
#define GUARD
struct A {};
#define CMD 5 // without this, all is well!
#endif
Run Code Online (Sandbox Code Playgroud)
Doxygen 1.8.11抱怨:
warning: Member GUARD (macro definition) of file a.h is not documented.
Run Code Online (Sandbox Code Playgroud)
第一个有趣的事情是警告提到a.h.第二个是如果删除了任何一条注释行,警告就会消失.这里发生了什么?
我知道来自不同翻译单元的静态变量初始化顺序的问题.但是,我的问题是在一个翻译单元内,事实上,在一个结构中:
template <int size>
struct SlidingTile {
using AllActions = std::array<int, size>;
using AllMDDeltas = std::array<int, size>;
int mdDelta(int i) const {
return mdDeltas_[i];
}
static AllActions computeAllActions() {
std::cout << "computeAllActions" << std::endl;
AllActions res;
for (int i = 0; i < size; ++i) res[i] = i;
return res;
}
static AllMDDeltas computeAllMDDeltas() {
std::cout << "Entered computeAllMDDeltas" << std::endl;
AllActions res;
for (int i = 0; i < size; ++i) res[i] = 10 * allActions_[i];
std::cout << "Exiting …Run Code Online (Sandbox Code Playgroud)