1 // Boost noncopyable.hpp header file --------------------------------------//
3 // (C) Copyright Beman Dawes 1999-2003. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // See http://www.boost.org/libs/utility for documentation.
9 #ifndef BOOST_CORE_NONCOPYABLE_HPP
10 #define BOOST_CORE_NONCOPYABLE_HPP
12 #include <boost/config.hpp>
16 // Private copy constructor and copy assignment ensure classes derived from
17 // class noncopyable cannot be copied.
19 // Contributed by Dave Abrahams
21 namespace noncopyable_ // protection from unintended ADL
23 #ifndef BOOST_NONCOPYABLE_BASE_TOKEN_DEFINED
24 #define BOOST_NONCOPYABLE_BASE_TOKEN_DEFINED
26 // noncopyable derives from base_token to enable Type Traits to detect
27 // whether a type derives from noncopyable without needing the definition
28 // of noncopyable itself.
30 // The definition of base_token is macro-guarded so that Type Trais can
31 // define it locally without including this header, to avoid a dependency
36 #endif // #ifndef BOOST_NONCOPYABLE_BASE_TOKEN_DEFINED
38 class noncopyable: base_token
41 #if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) && !defined(BOOST_NO_CXX11_NON_PUBLIC_DEFAULTED_FUNCTIONS)
42 BOOST_CONSTEXPR noncopyable() = default;
43 ~noncopyable() = default;
48 #if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
49 noncopyable( const noncopyable& ) = delete;
50 noncopyable& operator=( const noncopyable& ) = delete;
52 private: // emphasize the following members are private
53 noncopyable( const noncopyable& );
54 noncopyable& operator=( const noncopyable& );
59 typedef noncopyable_::noncopyable noncopyable;
63 #endif // BOOST_CORE_NONCOPYABLE_HPP