W Ubuntu 14.10 dostępny jest tylko boost w wersji 1.55, więc trzeba ściągnąć źródła samodzielnie:
wget -c http://sourceforge.net/projects/boost/files/boost/1.57.0/boost_1_57_0.tar.gz/download mv download boost_1_57.tar.gz tar -zxv boost_1_57.tar.gzPodczas kompilacji trzeba jeszcze wskazać gdzie są nasze pliki nagłówkowe:
g++ -std=c++14 -I/home/beru/boost_1_57_0/ main.cppA teraz testowanie. auto w trakcie dedukcji typu usuwa modyfikatory const i volatile.
#include <iostream>
#include <vector>
#include <boost/type_index.hpp>
using namespace std;
int main()
{
const vector<int> val1;
auto a = val1;
auto& b = val1;
int val2 = 44;
const int* p = &val2;
auto c = p;
cout << "For a: " << boost::typeindex::type_id_with_cvr<decltype(a)>().pretty_name() << endl;
cout << "For b: " << boost::typeindex::type_id_with_cvr<decltype(b)>().pretty_name() << endl;
cout << "For c: " << boost::typeindex::type_id_with_cvr<decltype(c)>().pretty_name() << endl;
return 0;
}
Wynik:For a: std::vector<int, std::allocator<int> > For b: std::vector<int, std::allocator<int> > const& For c: int const*
Brak komentarzy:
Prześlij komentarz