【发布时间】:2017-10-15 14:45:27
【问题描述】:
我正在尝试编译一个 C++ 库(使用 gcc 5.3.1-14ubuntu2)并遇到这种类型的错误:
> In file included from
> /root/pitchfork/workspace/unanimity/include/pacbio/consensus/ModelConfig.h:49:0,
> from /root/pitchfork/workspace/unanimity/src/models/P6C4NoCovModel.cpp:42:
> /root/pitchfork/workspace/unanimity/include/pacbio/data/internal/BaseEncoding.h:119:31:
> error: explicitly defaulted function 'constexpr
> PacBio::Data::detail::NCBI2na&
> PacBio::Data::detail::NCBI2na::operator=(const
> PacBio::Data::detail::NCBI2na&)' cannot be declared as constexpr
> because the implicit declaration is not constexpr:
> inline constexpr NCBI2na& operator=(const NCBI2na&) = default;
导致麻烦的代码部分是:
class NCBI2na
{
public:
static inline constexpr NCBI2na FromASCII(const char base) { return NCBI2na{base}; }
static inline constexpr NCBI2na FromRaw(const uint8_t raw) { return NCBI2na{raw}; }
public:
~NCBI2na() = default;
inline constexpr NCBI2na(const NCBI2na&) = default;
inline constexpr NCBI2na(NCBI2na&&) = default;
inline constexpr NCBI2na& operator=(const NCBI2na&) = default;
inline constexpr NCBI2na& operator=(NCBI2na&&) = default;
};
似乎引起麻烦的代码部分是“= default”。这也可能是相关的
我环顾四周,但到目前为止找不到解决此问题的方法。 以下是一些可能有所帮助的类似问题:
constexpr defining static data member of literal type that is declared const constructor of derived class cannot be constexpr if base class contains array member
【问题讨论】:
-
It works 与 GCC 7.2.0 以及 Clang 3.8.0。