Ich versuche, den Intel C++ - Compiler verwenden verschiedene Standard-Bibliothek C++ - Header als die Standard-Compiler. Die Header, die der Compiler standardmäßig verwenden würde, definieren leider keinen bestimmten Typ Trait/Funktion, die ich brauche.Verwenden von verschiedenen Standard C++ - Bibliothek Header mit Intel-Compiler
$ icpc --version
icpc (ICC) 16.0.2 20160204
Copyright (C) 1985-2016 Intel Corporation. All rights reserved.
Die Header ich in
ls /opt/crtdc/gcc/4.8.5-4/include/c++/4.8.5/:
algorithm cfenv condition_variable cstring ext iostream numeric sstream tuple
array cfloat csetjmp ctgmath fenv.h istream ostream stack typeindex
atomic chrono csignal ctime forward_list iterator parallel stdexcept typeinfo
backward cinttypes cstdalign cwchar fstream limits profile streambuf type_traits
bits ciso646 cstdarg cwctype functional list queue string unordered_map
bitset climits cstdbool cxxabi.h future locale random system_error unordered_set
cassert clocale cstddef debug initializer_list map ratio tgmath.h utility
ccomplex cmath cstdint decimal iomanip memory regex thread valarray
cctype complex cstdio deque ios mutex scoped_allocator tr1 vector
cerrno complex.h cstdlib exception iosfwd new set tr2 x86_64-redhat-linux
befinden sich verwenden möchten Aber was auch immer ich versuche, ich entweder bekommen
icpc -std=c++11 -o test test.cc -Qlocation,cxxinc,/opt/crtdc/gcc/4.8.5-4/include/c++/4.8.5/
error: namespace "std" has no member "declval"
(hier denke ich, der Compiler verwendet es Standard-Header Standort) oder
icpc -std=c++11 -o test test.cc -nostdinc++ -Qlocation,cxxinc,/opt/crtdc/gcc/4.8.5-4/include/c++/4.8.5/
test.cc(2): catastrophic error: cannot open source file "utility"
#include <utility> // std::declval
(sie e es verwendet überhaupt keine C++ - Header, weil das -nostdinC++ - Flag alle zusammen deaktiviert, denke ich)
Das Programm test.cc übt nur die C++ 11-Standardbibliothek aus, die ich brauche:
// declval example
#include <utility> // std::declval
#include <iostream> // std::cout
struct A { // abstract class
virtual int value() = 0;
};
class B : public A { // class with specific constructor
int val_;
public:
B(int i,int j):val_(i*j){
std::cout << "ctor\n";
}
int value() {return val_;}
};
int main() {
decltype(std::declval<A>().value()) a; // int a
decltype(std::declval<B>().value()) b; // int b
decltype(B(0,0).value()) c; // same as above (known constructor)
a = b = B(10,2).value();
std::cout << a << '\n';
return 0;
}
EDIT:
Nur um sicherzugehen diese richtig motiviert zu haben. Die standardmäßigen C++ 11-Header auf diesem System unterstützen nicht die Angabe std :: declval. Deshalb versuche ich, die GCC zu benutzen, die es unterstützen.
$ icpc -std=c++11 -o test test.cc
opa.cc(19): error: namespace "std" has no member "declval"
decltype(std::declval<A>().value()) a; // int a
^
Ich bezweifle, dass es eine fruchtbare Übung ist. Ich habe Angst, dass Tage, an denen die Standard-Bibliothek außerhalb ihres Compilers verwendet werden kann, weg sind - es gibt heutzutage zu viele Compiler-Intrinsic. Aber welche Art von Eigenschaft brauchst du? – SergeyA