Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Extracting type from a vector instance

30 views
Skip to first unread message

Doug Mika

unread,
May 20, 2015, 4:36:27 PM5/20/15
to
Why would the following not work?

int main(){
vector<double> vd;
decltype(vd.value_type) otherDouble = 2.2;
}

Thanks.

Paavo Helde

unread,
May 20, 2015, 4:57:47 PM5/20/15
to
Doug Mika <doug...@gmail.com> wrote in news:6f7085a7-cf81-4ec3-a2b6-
895f58...@googlegroups.com:
value_type is already a type, so applying decltype on it does not make
sense. I guess this is what you are after:

#include <vector>
int main(){
std::vector<double> vd;
decltype(vd)::value_type otherDouble = 2.2;
}

hth
Paavo

0 new messages