测试离奇报错,在线求解决

本来想着能不能new成新的bool值,然后就这样了


#define supple
#include <algorithm>
#include <typeinfo>
#include <iostream>
using namespace std;
int main()
{
    boolean<1> *p;
     print<decltype(*p), ' '>::display();
    p = new boolean<9>;
    print<decltype(*p), ' '>::display();
    return 0;
}

报错(Test.cpp):

9 27 : expected ';' before '::' token
9 38 :statement cannot resolve address of overloaded function
11 26 : expected ';' before '::' token
11 37 : statement cannot resolve address of overloaded function

stuuct printstruct boolean 的代码

struct boolean_tag {
    static const bool is_pair = false;
    static const bool is_null = false;
    static const bool is_number = false;
    static const bool is_boolean = true;
    static const bool is_symbol = false;
    static const bool is_character = false;
};

template <bool flag>
struct boolean {
    static const bool value = flag;
    using type = boolean<flag>;
    using tag = boolean_tag;
};

template <typename T, char end = 0>
struct print {
    static char display() {
        std::cout << T::type::value;
        if (end) std::cout << end;
        return end;
    }
};

改成这样:

#define supple
#include <algorithm>
#include <typeinfo>
#include <iostream>
using namespace std;
int main()
{
    boolean<1> *p = new boolean<1>;
     print<decltype(*p), ' '>::display();
    p = new boolean<9>;
    print<decltype(*p), ' '>::display();
    return 0;
}

报错(templates.hpp):

142 13'boolean<true>&' is not a class, struct, or union type

我寻思
decltype(*p)
即boolean<1>&怎么就不是类型了?

总之赶紧help本蒟蒻o(╥﹏╥)o

dd

dd