/* NOCOPY.hpp - some flavours of non-copyable entities Copyright (C) Lumiera.org 2012, Hermann Vosseler This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /** @file nocopy.hpp ** Mix-Ins to allow or prohibit various degrees of copying and cloning. ** @todo 2016 this could be organised way better. Also C++11 offers a way more ** elegant way of expressing the intention. We could get rid of `boost::noncopyable` ** The basic idea of using a marker mixin seems very reasonable though. ////////////////////////////TICKET #1084 */ #ifndef LIB_NOCOPY_H #define LIB_NOCOPY_H #include namespace util { /** * any copy and copy construction prohibited */ class no_copy : boost::noncopyable { }; /** * classes inheriting from this mixin * may be created by copy-construction, * but any copy-assignment is prohibited. * @note especially this allows returning * by-value from a builder function, * while prohibiting any further copy */ class no_copy_by_client { protected: ~no_copy_by_client() {} no_copy_by_client() {} no_copy_by_client (no_copy_by_client const&) {} no_copy_by_client const& operator=(no_copy_by_client const&) { return *this; } }; } // namespace util #endif /*LIB_NOCOPY_H*/