請考慮下面的代碼片段: template<class E>
class vector_expression
{
public:
auto size() const {
return static_cast<E const&>(*this).size();
}
auto operator[](/* type equal to E::size_type
我正在構建具有計算內核的表達式模板的代碼。我的問題是非常短的:爲什麼GNU G ++給出在下面的例子中包含+=行了段錯誤(4.9.1,與-O3編譯): // Like this it crashes
auto expression = Ix_h(Ix(u));
ut += expression;
但不是當我輸入的等效代碼: // But like this it does not
ut
假設我們有一個matrix類,它利用表達式模板,以便代理對象用於使編譯器優化複合表達式。現在 ,這是很自然的創造row類的格式如下: namespace detail
{
template<class E>
class row
: public vector_expression<row<E>>
{
public:
using si