1 #ifndef libjmmcg_core_non_copyable_hpp 2 #define libjmmcg_core_non_copyable_hpp 3 /****************************************************************************** 4 ** $Header: svn+ssh://jmmcg@svn.code.sf.net/p/libjmmcg/code/trunk/libjmmcg/core/non_copyable.hpp 2055 2017-05-13 19:35:47Z jmmcg $ 5 ** 6 ** Copyright © 2008 by J.M.McGuiness, jmmcg@sourceforge.net & coder@hussar.me.uk 7 ** 8 ** This library is free software; you can redistribute it and/or 9 ** modify it under the terms of the GNU Lesser General Public 10 ** License as published by the Free Software Foundation; either 11 ** version 2.1 of the License, or (at your option) any later version. 12 ** 13 ** This library is distributed in the hope that it will be useful, 14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 ** Lesser General Public License for more details. 17 ** 18 ** You should have received a copy of the GNU Lesser General Public 19 ** License along with this library; if not, write to the Free Software 20 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 */ 22 23 #include "blatant_old_msvc_compiler_hacks.hpp" 24 25 namespace jmmcg { 26 27 /// Used to try to help ensure that an object cannot be copied. 28 class non_assignable { 29 void operator=(non_assignable const &)=delete; 30 void operator=(non_assignable &&)=delete; 31 }; 32 33 /// Used to try to help ensure that an object cannot be copied. 34 class non_copyable : protected non_assignable { 35 protected: 36 non_copyable()=default; 37 ~non_copyable()=default; 38 39 non_copyable(non_copyable const &)=delete; 40 non_copyable(non_copyable &&)=delete; 41 void operator=(non_copyable const &)=delete; 42 void operator=(non_copyable &&)=delete; 43 }; 44 45 } 46 47 #endif