के साथ विभिन्न मानक सी ++ लाइब्रेरी हेडर का उपयोग करके मैं इंटेल सी ++ कंपाइलर को संकलक के डिफ़ॉल्ट वाले की तुलना में विभिन्न मानक लाइब्रेरी सी ++ हेडर का उपयोग करने की कोशिश कर रहा हूं। हेडर जो संकलक प्रति डिफ़ॉल्ट रूप से उपयोग करेंगे दुर्भाग्यवश मुझे आवश्यक किसी विशेष प्रकार के विशेषता/फ़ंक्शन को परिभाषित नहीं करते हैं।इंटेल कंपाइलर
$ icpc --version
icpc (ICC) 16.0.2 20160204
Copyright (C) 1985-2016 Intel Corporation. All rights reserved.
हेडर मैं उपयोग करने के लिए
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
में स्थित हैं करना चाहते हैं लेकिन जो कुछ भी मैं कोशिश, मैं या तो
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"
(यहाँ प्राप्त कर रहा संकलक का उपयोग करता है लगता है कि यह डिफ़ॉल्ट शीर्ष लेख है स्थान) या
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
(उसे ई इसकी वजह -nostdinC++ झंडा यह सब एक साथ अक्षम कर देता है, किसी भी सी ++ हेडर का उपयोग नहीं करता, मुझे लगता है)
test.cc कार्यक्रम सिर्फ सी ++ 11 मानक पुस्तकालय विशेषता यह है कि मैं आवश्यकता होगी व्यायाम:
// 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;
}
संपादित करें:
बस इस ठीक से प्रेरित है करने के लिए सुनिश्चित किया जाना है। इस सिस्टम पर डिफ़ॉल्ट C++ 11 शीर्षलेख std :: declval का समर्थन नहीं करते हैं। यही कारण है कि मैं जीसीसी लोगों का उपयोग करने की कोशिश करता हूं जो इसका समर्थन करते हैं।
$ 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
^
मुझे संदेह है कि यह एक उपयोगी व्यायाम है। मैं पहले दिन हूं जब मानक लाइब्रेरी का इस्तेमाल इसके कंपाइलर के बाहर किया जा सकता है - आजकल वहां बहुत सारे कंपाइलर इंट्रिनिसिक हैं। लेकिन आपको किस प्रकार की विशेषता है? – SergeyA