constexpr类的非静态成员。他们真的编译时间吗?

时间:2017-04-12 04:18:53

标签: c++ c++11 constexpr

考虑使用constexpr非静态成员函数的类。

template <int k> class A { A() {} };
template <> class B : public A <k> {
    B() : A{} {}
    constexpr int foo() const { return k+42; } 
}

foo()是否真的用B的任何对象编译时间? constexpr成员怎么样?

template <int k> class A { A() {} };
template <> class B : public A <k> {
    B() : A{} {}
    constexpr int foo_var = k+42;
}

访问foo_var会被编译时替换吗? B会在其对象内存布局中使用foo_var吗?

std::array<T,N>::size() ??

怎么样?

0 个答案:

没有答案
相关问题