相关疑难解决方法(0)

与static_assert和boost :: hana相关的Clang编译错误

考虑以下在Clang 3.8上成功编译的问题-std=c++14.

#include <boost/hana.hpp>

namespace hana = boost::hana;

int main() {
    constexpr auto indices = hana::range<unsigned, 0, 3>();
    hana::for_each(indices, [&](auto i) {
        hana::for_each(indices, [&](auto j) {
            constexpr bool test = (i == (j == i ? j : i));
            static_assert(test, "error");
        });
    });
}
Run Code Online (Sandbox Code Playgroud)

测试是非常不敏感的,但这不是重点.现在考虑一个替代版本,其中测试直接放在static_assert:

#include <boost/hana.hpp>

namespace hana = boost::hana;

int main() {
    constexpr auto indices = hana::range<unsigned, 0, 3>();
    hana::for_each(indices, [&](auto i) {
        hana::for_each(indices, [&](auto j) {
            static_assert((i == (j == i ? j …
Run Code Online (Sandbox Code Playgroud)

c++ static-assert clang++ boost-hana

5
推荐指数
1
解决办法
511
查看次数

标签 统计

boost-hana ×1

c++ ×1

clang++ ×1

static-assert ×1