在每一个渲染我试过,code而且code-block似乎有相同的结果:一个代码块.两者都生成完全相同的html - 包括类和标签类(使用我认为它是docutils?):
<pre class="code [language] literal-block">
Run Code Online (Sandbox Code Playgroud)
那么,有什么区别?为什么我们两个都有?是否有任何渲染器以不同的方式呈现它们?有语义差异吗?
甚至有可能使用与简单指针不同的函数来调用在编译时已知大小的数组?我尝试了所有知道的技巧。
template <typename T>
int length(const T* t) {
return -1;
}
template<typename T, int N>
int length(const T (&)[N]) {
return N;
}
int main() {
return length("abc");
}
Run Code Online (Sandbox Code Playgroud)
gcc给出以下错误:
source>: In function 'int main()':
<source>:13:24: error: call of overloaded 'length(const char [4])' is ambiguous
return length("abc");
^
<source>:13:24: note: candidates are:
<source>:2:5: note: int length(const T*) [with T = char]
int length(const T* t) {
^
<source>:7:5: note: int length(const T (&)[N]) [with T = char; int N …Run Code Online (Sandbox Code Playgroud)