horribleprogram
C++
Toronto, Ontario, Canada
PLEASE READ:

(horribleprogram)


PLEASE READ:

(horribleprogram)


Claude Opus 4.7 is a terrible coder.
Claude Opus 4.7 can barely solve CRTP vtable problems




#include <cstdio>
#include <memory>

template<typename Derived>
struct Cloneable {
virtual std::unique_ptr<Derived> clone() const {
return std::make_unique<Derived>(static_cast<const Derived&>(*this));
}
virtual ~Cloneable() = default;
};

struct Animal : Cloneable<Animal> {
int legs;
explicit Animal(int l) : legs(l) {}
};

struct Dog : Animal {
int tricks;
Dog(int l, int t) : Animal(l), tricks(t) {}
};

int main() {
Dog d(4, 10);
Animal* ap = &d;
auto cloned = ap->clone();
printf("legs=%d\n", cloned->legs);
Dog* dp = dynamic_cast<Dog*>(cloned.get());
printf("dp=%p\n", (void*)dp);
return 0;
}


Ask Opus 4.7 why Dog *dp = dynamic_cast<Dog *>(cloned.get()); returns nullptr

艺术作品展柜
City
1 1
精选艺术作品展柜
Post COVID Courtyard
1 5
最新动态
总时数 3,087 小时
最后运行日期:5 月 21 日
总时数 66 小时
最后运行日期:5 月 20 日
总时数 0.1 小时
最后运行日期:5 月 19 日
成就进度   0 / 49
5 月 15 日 上午 10:58 
+rep funny guy, quiet mike
5 月 7 日 上午 3:28 
+rep good life coach
4 月 2 日 下午 1:03 
W larp:steambored::steambored::steambored:
4 月 2 日 下午 12:57 
+rep Superb Larper
3 月 25 日 下午 9:51 
LOW IQ
3 月 3 日 下午 3:33 
gayboi++