Error Handling issue in NonCopyable Interface
Hello, I am having error handling issues that is in regards to the NonCopyable Interface library. Here is the source code: #include <boost/noncopyable.hpp> #include <iostream> class A : public boost::noncopyable { public: A() { std::cout << "In A \n" << std::endl; } class AnError {}; void Func() { if () //error condition throw AnError(); } }; int main() { try { A object1; A object2(object1); object1 = object2; } catch (A::AnError) { //tell user about error. } return 0; } } So far, I have tried on the forums in CPlusPlus.com and MSDN, but no responses. Since that Boost.org has created and authored the NonCopyable.hpp library, I would like to get some assistance. Can anybody give me some solutions on how to suppress any compilation errors? Thanks in advance. Email me back at the Cc: if you have any answers or comments with detailed information and examples. John P.
On 8/08/2014 15:27, John Pallino wrote:
I am having error handling issues that is in regards to the NonCopyable Interface library. [...] if () //error condition
This wouldn't compile.
A object2(object1); object1 = object2;
The entire purpose of boost::noncopyable is to prevent these two lines from compiling.
Can anybody give me some solutions on how to suppress any compilation errors?
You didn't say what the errors you're getting are, so it's not surprising you didn't get many responses before. But if my crystal ball is working and it relates to one of the three lines above, then congratulations, your compiler is working properly. Also, for future reference, questions on how to use the Boost libraries belong on the boost-user mailing list, not boost-devel.
participants (2)
-
Gavin Lambert
-
John Pallino