2 // Copyright (c) 2009-2016 Vladimir Batov.
3 // Use, modification and distribution are subject to the Boost Software License,
4 // Version 1.0. See http://www.boost.org/LICENSE_1_0.txt.
6 #ifndef BOOST_MAKE_DEFAULT_HPP
7 #define BOOST_MAKE_DEFAULT_HPP
11 /// @details A considerable number of libraries require an instance of a class
12 /// provided (storage created and initialized). For example,
16 /// istream >> result;
18 /// In generic code that results in the Default Constructibility requirement imposed
19 /// on every type 'Type' to be used with the respective code. Inevitably, that requirement
20 /// a) either excludes all the classes that for various reasons do not meet that requirement or
21 /// b) imposes certain (not necessarily desirable) design/implementation onto respective classes.
23 /// Deployment of boost::make_default() eliminates the Default Constructibility requirement with
25 /// Type result = boost::make_default<Type>();
27 /// istream >> result;
29 /// Classes with no default constructor can now be included via a boost::make_default() specialization:
33 /// template<> inline Type make_default<Type>() { return Type(parameters); }
37 template<typename T> T make_default() { return T(); }
40 #endif // BOOST_MAKE_DEFAULT_HPP