Add use_default to Core

This commit is contained in:
Glen Fernandes 2019-02-22 16:51:33 -05:00
parent 266076f83b
commit 4ea704e80a
5 changed files with 82 additions and 0 deletions

View File

@ -58,3 +58,4 @@ criteria for inclusion is that the utility component be:
[include swap.qbk]
[include typeinfo.qbk]
[include uncaught_exceptions.qbk]
[include use_default.qbk]

47
doc/use_default.qbk Normal file
View File

@ -0,0 +1,47 @@
[/
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
]
[section:use_default use_default]
[section Overview]
The header <boost/core/use_default.hpp> provides the type `boost::use_default`
which is used by other Boost libraries as a sentinel type in a templates to
indicate defaults.
[endsect]
[section Example]
```
template<class Derived, class Base,
class Value = boost::use_default,
class CategoryOrTraversal = boost::use_default,
class Reference = boost::use_default,
class Difference = boost::use_default>
class iterator_adaptor;
template<class Value>
class node_iterator
: public iterator_adaptor<node_iterator<Value>, Value*,
boost::use_default, boost::forward_traversal_tag>;
```
[endsect]
[section Reference]
```
namespace boost {
struct use_default { };
}
```
[endsect]
[endsect]

View File

@ -0,0 +1,17 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_CORE_USE_DEFAULT_HPP
#define BOOST_CORE_USE_DEFAULT_HPP
namespace boost {
struct use_default { };
} /* boost */
#endif

View File

@ -133,6 +133,8 @@ run empty_value_final_test.cpp ;
run quick_exit_test.cpp ;
run-fail quick_exit_fail.cpp ;
compile use_default_test.cpp ;
lib lib_typeid : lib_typeid.cpp : <link>shared:<define>LIB_TYPEID_DYN_LINK=1 ;
run test_lib_typeid.cpp lib_typeid : : : <link>shared : test_lib_typeid_shared ;

15
test/use_default_test.cpp Normal file
View File

@ -0,0 +1,15 @@
/*
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/core/use_default.hpp>
template<class, class = boost::use_default>
struct type { };
template class type<int>;
template class type<void, boost::use_default>;