C++ STL containers don't allow instantiation with incomplete types; it is undefined behavior.
Is this a valid "trick" to get around that restriction? Or does this trick still have undefined behavior?
#include <vector>
template<template<class, class> class Vector = std::vector>
struct my_incomplete_vector
{
struct Element;
// Element is incomplete here, but does it matter anymore?
typedef Vector<Element, std::allocator<Element> > type;
struct Element { typename type::iterator value; };
};
int main()
{
my_incomplete_vector<>::type v;
v.resize(1);
// this isn't normally possible without incomplete types
v[0].value = v.begin();
return 0;
}