Вы также можете попробовать:
vector[cumsum(vector %in% c("b", "e")) == 1][-1]
[1] "c" "" "d"
It uses the equivalent of the default constructor for ints, which is to zero initialise them. You can do it explicitly:
int n = int();
will set n to zero.
Note that default construction is only used and required if the vector is given an initial size. If you said:
vector <X> v;
there is no requirement that X have a default constructor.
std::vector<Type> a(10); // T could be userdefined or basic data type
Вектор обычно вызывает default
для типа, на который он указывает: Type ()