Originated from this CodeReview topic:
#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
}
How could std::is_constructible<aggregate_wrapper<foo_t>>::value
be true when aggregate_wrapper<foo_t> v;
does not actually compile?
aggregate_wrapper<foo_t>
can certainly be constructed, just not viaaggregate_wrapper<foo_t> v;
. – Telefilmis_default_constructible<T>
andis_constructible<T>
(which means thatArgs...
is an empty pack) are equivalent. – Dollydolman