<type> is not derived from <type>
-
Hoi

Ich hab ein Problem das mich absolut stutzig macht:
Erst mal der Code:
/** * Class used to iterate over a list of processes */ template <typename Info> class basic_enum_process { private: std::vector<Info> m_snap; public: /** * Default ctor */ basic_enum_process() : m_snap(0) { } /** * Optional constructor calling make_snapshot() * @argument Ignored as a pid is senseless in this context */ basic_enum_process(pid_t) { make_snapshot(0); } /** * Makes a snapshot of all running processes * @argument Ignored as a pid is senseless in this context */ void make_snapshot(pid_t = 0) { impl::make_process_snapshot<Info>(m_snap); } /** * Returns an iterator to the first element in the snapshot */ std::vector<Info>::const_iterator begin() const { return m_snap.begin(); } /** * Returns an iterator to the last element in the snapshot */ std::vector<Info>::const_iterator end() const { return m_snap.end(); } /** * Returns the amount of snapped processes */ size_t get_amount() const { return m_snap.size(); } /** * Frees memory allocated for snapshot */ void free_memory() const { m_snap.clear(); } };Aus welchem Grund haut mir der Compiler bei dem Code die Fehlermeldung um die Ohren
system_snapshots.hpp:61: error: type ‘std::vector<Info, std::allocator<_Tp1> >’ is not derived from type ‘memworm::basic_enum_process<Info>’bei dem Versuch die Iteratoren zureückzugeben?
Grüße,
Flo
-
typename davor schreiben. Der Compiler weiß nicht, was ein
std::vector<Info>::const_iteratorist, wenn du es ihm nicht explizit sagst, da er noch nicht weiß, wasInfoist. Könnte ja auch eine Zahl oder ein Funktionszeiger oder sonstwas sein.
-
Upps, danke!
Kanns sein dass der MSVC++ das aber trotzdem kompiliert?
Früher habe ich es eigentlich immer so geschrieben, bin GCC Neuling
-
Ethon schrieb:
Kanns sein dass der MSVC++ das aber trotzdem kompiliert?
Früher habe ich es eigentlich immer so geschrieben, bin GCC Neuling
Ja, kann sein. Soweit ich weiß, macht MSVC++ kein richtiges Zwei-Phasen-Lookup. Das 'typename' hier wegzulassen ist aber nicht erlaubt. Der GCC ist da recht pingelig.