gpt4 book ai didi

c++ - std::is_constructible 没有给出正确的结果

转载 作者:可可西里 更新时间:2023-11-01 18:39:00 26 4
gpt4 key购买 nike

<分区>

源自this CodeReview 主题:

#include <cstddef>
#include <algorithm>
#include <iostream>
#include <type_traits>
#include <utility>

template <typename T>
class aggregate_wrapper : public T {
private:
using base = T;

public:
using aggregate_type = T;

template <typename... Ts>
aggregate_wrapper(Ts&&... xs)
: base{std::forward<Ts>(xs)...} {
// nop
}
};

struct foo_t {
foo_t(int) {}
};

int main() {
std::cout << std::is_constructible<foo_t>::value << std::endl;
std::cout << std::is_constructible<aggregate_wrapper<foo_t>>::value << std::endl;
// aggregate_wrapper<foo_t> v; // won't compile
}

怎么可能std::is_constructible<aggregate_wrapper<foo_t>>::value aggregate_wrapper<foo_t> v; 时为真实际上不编译?

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com