xlc:模板类的sizeof不起作用

时间:2017-01-17 05:52:25

标签: c++ templates xlc

我在模板参数中使用sizeof(),如下所示:

// Making a svg line animation through Vivus.js, which works fine

var svg_product =
new Vivus('product', {
    type: 'scenario',
    duration: 100
});

// Make the <g id="text"> invisible before the animation is finished

var hidefirst = document.getElementById("text");
hidefirst.style.opacity = 0;

// Detect if the line animation is finished using strokeDashoffset

var line = document.getElementById("XMLID_202_");
var lineDetect = window.getComputedStyle(line).strokeDashoffset;

// After the line animation is finished, make <text> visible
// But the code seems doesn't work

if (lineDetect == "0px") {
    hidefirst.style.opacity = 1;
}

由于某种原因,xlc ++决定#include <iostream> template<class A> struct Foo { A a; }; template<class A, size_t S = sizeof(Foo<A>)> class Bar { public: Bar() { // prints 4, as expected std::cout << sizeof(Foo<A>) << std::endl; // prints 1! why? std::cout << S << std::endl; } }; int main(int, char**) { Bar<int> foo; } 作为默认模板参数导致1.为什么会这样?这是编译器错误吗?它在Visual Studio 2015中打印4个。

我正在使用xlc版本sizeof(Foo<A>)

1 个答案:

答案 0 :(得分:1)

它可能是编译器中的错误,已在AIX上修复但在Z

上没有修复

在AIX上测试最新版本(即ptf) V13.1.3预期结果 V13.1预期结果 V12.1预期结果 V11.1预期结果

在ZOS上 V2R1失败 V2R2失败

如果您报告错误,我们可以将修复程序放入V2R1。