Boost noncopyable funktioniert nicht
-
BTW:
"The public keyword in the inheritance syntax means that publicly accessible members inherited from the base class stay publicly accessible in the derived class".
Da aber assigment operator/copy constructor bereits in der Basisklasse "private" sind, spielt es keine Rolle, ob private, protected oder pubic vererbt wird, oder irre ich mich jetzt ?
-
Bekommst du eigentlich die hier?
http://msdn.microsoft.com/en-us/library/3tdb471s(VS.80).aspx
-
ja, C4275 bekomme ich. Aber ich verstehe den Zusammenhang nicht.
BTW, wenn das der Grund wäre, könnte man boost::uncopyable ja gar nicht (bzw. das Konzept dahinter) immer sicher verwenden.
Warum ist das nicht dokumentiert bzw. fällt das niemandem auf ?
-
Und es wird noch besser: (kleineres beispiel, eine DLL):
DLLmain.hpp:
#include "boost/noncopyable.hpp"# if defined(UNCOPYABLETESTDLL_EXPORTS)
# define DLL_API __declspec(dllexport)
# else
# define DLL_API
# endifclass DLL_API AnotherNonNormalCopyClass: private boost::noncopyable
{
};class YetAnotherNonNormalCopyClass: public AnotherNonNormalCopyClass
{
public:
virtual AnotherNonNormalCopyClass* clone();
};
DLLmain.cpp:
#include "DLLmain.hpp"AnotherNonNormalCopyClass* YetAnotherNonNormalCopyClass::clone()
{
return new YetAnotherNonNormalCopyClass(*this);
}Ich verstehe das nicht: das kompiliert/linkt !.....

-
wie sieht es auf der Nutzerseite aus, also __declspec(dllimport) ?
-
Wie meinst Du das genau ? Ich exportiere ja noch keine Symbole....?
-
Doch, die Klasse.
-
PM1302 schrieb:
Und es wird noch besser: (kleineres beispiel, eine DLL):
DLLmain.hpp:
#include "boost/noncopyable.hpp"# if defined(UNCOPYABLETESTDLL_EXPORTS)
# define DLL_API __declspec(dllexport)
# else
# define DLL_API
# endifclass DLL_API AnotherNonNormalCopyClass: private boost::noncopyable
{
};class YetAnotherNonNormalCopyClass: public AnotherNonNormalCopyClass
{
public:
virtual AnotherNonNormalCopyClass* clone();
};
DLLmain.cpp:
#include "DLLmain.hpp"AnotherNonNormalCopyClass* YetAnotherNonNormalCopyClass::clone()
{
return new YetAnotherNonNormalCopyClass(*this);
}Ich verstehe das nicht: das kompiliert/linkt !.....

Bei mir auf jeden fall nicht
d:\workspace\dll_test\dll_test\main.h(11) : error C2248: 'boost::noncopyable_::noncopyable::noncopyable' : cannot access private member declared in class 'boost::noncopyable_::noncopyable'
1> d:\develop\include\boost\noncopyable.hpp(27) : see declaration of 'boost::noncopyable_::noncopyable::noncopyable'
1> d:\develop\include\boost\noncopyable.hpp(22) : see declaration of 'boost::noncopyable_::noncopyable'
1> This diagnostic occurred in the compiler generated function 'AnotherNonNormalCopyClass::AnotherNonNormalCopyClass(const AnotherNonNormalCopyClass &)'
-
@Zeus: Hast Du UNCOPYABLETESTDLL_EXPORTS definiert?
-
Ok, welcher Compiler/Linker ? ServicePack ?
-
Ja, ok, die Klasse...sorry, mein Fehler
-
LordJaxom schrieb:
@Zeus: Hast Du UNCOPYABLETESTDLL_EXPORTS definiert?
Oh irgendwas musste ich ja vergessen mit UNCOPYABLETESTDLL_EXPORTS gibst nur 1 Warnung <.<
-
Folgender Code in einem DLL-Projekt erzeugt einen internen Compilerfehler in MSVC 2005:
class __declspec(dllexport) base { private: base( const base& ); }; class __declspec(dllexport) derived : public base { public: void foo() { derived p( *this ); } };Übrigens auch ohne dllexport an der Basisklasse.
-
@MDK: Es geht aber nicht um die Compiler-Warning, sondern, dass die (beasichtigte und erwartete) Wirkung von boost::noncopyable aufgehoben wird und zwar so, dass es der Entwickler zur Compile/Link Zeit nichts bemerkt. Erst zur Laufzeit gibt es "komisches" Verhalten i.e. zeigt sich, dass clone() eben doch nicht funktioniert z.B. unitialisierte Member etc, aber keinen Crash
-
PM1302 schrieb:
@MDK: Es geht aber nicht um die Compiler-Warning, sondern, dass die (beasichtigte und erwartete) Wirkung von boost::noncopyable aufgehoben wird
Es ging mir nur darum, zu demonstrieren, dass der Compiler selbst mit diesem Konstrukt offenbar Probleme hat, und ich mich deshalb über nichts wundern würde, was da passiert.
MSVC 2008 hat übrigens dasselbe Problem.
-
Also Compiler-Fehler ? Hat das mal jemand mit einem anderen Compiler probiert ?
-
Also Compiler-Fehler ? Hat das mal jemand mit einem anderen Compiler probiert ?
-
Ich glaube nicht, dass das genau dieses Problem ist, aber mit noncopyable hat Microsoft auch an anderer Stelle Probleme

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=101735