Entstanden aus this Codereview Thema:std :: is_constructible gibt nicht das richtige Ergebnis
#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
}
Wie konnte std::is_constructible<aggregate_wrapper<foo_t>>::value
wahr sein, wenn aggregate_wrapper<foo_t> v;
eigentlich nicht kompilieren?
Vielleicht machst du mental * constructible * mit * default construcible *? Ein 'aggregate_wrapper' kann sicherlich konstruiert werden, nur nicht über 'aggregate_wrapper v;'. –
@ M.M Nein, 'is_default_constructible' und 'is_constructible ' (was bedeutet, dass 'Args ...' ist eine leere Packung) sind gleichwertig. –
Nicht sicher, warum das wieder geöffnet wurde; die dup ist direkt am point. –