BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslstl_utility.h
Go to the documentation of this file.
1/// @file bslstl_utility.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslstl_utility.h -*-C++-*-
8#ifndef INCLUDED_BSLSTL_UTILITY
9#define INCLUDED_BSLSTL_UTILITY
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bslstl_utility bslstl_utility
15/// @brief Provide implementations for utilities not in the system library.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslstl
19/// @{
20/// @addtogroup bslstl_utility
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslstl_utility-purpose"> Purpose</a>
25/// * <a href="#bslstl_utility-classes"> Classes </a>
26/// * <a href="#bslstl_utility-description"> Description </a>
27/// * <a href="#bslstl_utility-usage"> Usage </a>
28///
29/// # Purpose {#bslstl_utility-purpose}
30/// Provide implementations for utilities not in the system library.
31///
32/// # Classes {#bslstl_utility-classes}
33///
34///
35/// **Canonical header:** bsl_utility.h
36///
37/// @see bsl+bslhdrs
38///
39/// # Description {#bslstl_utility-description}
40/// This component is for internal use only. Please include
41/// `<bsl_utility.h>` instead. This component provides a namespace for free
42/// functions implementing standard utilities that are not provided by the
43/// underlying standard library implementation. For example, `as_const` is a
44/// C++17 utility, and it is provided here for code using C++03.
45///
46/// ## Usage {#bslstl_utility-usage}
47///
48///
49/// This component is for use by the `bsl+bslhdrs` package. Use
50/// `bsl_utility.h` directly.
51/// @}
52/** @} */
53/** @} */
54
55/** @addtogroup bsl
56 * @{
57 */
58/** @addtogroup bslstl
59 * @{
60 */
61/** @addtogroup bslstl_utility
62 * @{
63 */
64
65#include <bslscm_version.h>
66
67#include <bslmf_addconst.h>
69#include <bsls_keyword.h>
70
71#include <utility>
72
73#ifndef BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
74#include <bsls_nativestd.h>
75#endif // BDE_DONT_ALLOW_TRANSITIVE_INCLUDES
76
77namespace bsl {
78
79#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
80 using std::as_const;
81#else
82/// return a reference offering non-modifiable access to the specified `t`.
83template <class TYPE>
86{
87 return t;
88}
89
90#ifdef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
91# ifndef BSLS_COMPILERFEATURES_SUPPORT_DELETED_FUNCTIONS
92# error "compiler supports rvalue references but not deleted functions"
93# endif
94
95template <class TYPE>
96void as_const(const TYPE&&) = delete;
97# endif // BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
98#endif // !BSLS_LIBRARYFEATURES_HAS_CPP17_BASELINE_LIBRARY
99
100} // close namespace bsl
101
102#endif // INCLUDED_BSLSTL_UTILITY
103
104// ----------------------------------------------------------------------------
105// Copyright 2022 Bloomberg Finance L.P.
106//
107// Licensed under the Apache License, Version 2.0 (the "License");
108// you may not use this file except in compliance with the License.
109// You may obtain a copy of the License at
110//
111// http://www.apache.org/licenses/LICENSE-2.0
112//
113// Unless required by applicable law or agreed to in writing, software
114// distributed under the License is distributed on an "AS IS" BASIS,
115// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
116// See the License for the specific language governing permissions and
117// limitations under the License.
118// ----------------------------- END-OF-FILE ----------------------------------
119
120/** @} */
121/** @} */
122/** @} */
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_KEYWORD_CONSTEXPR
Definition bsls_keyword.h:588
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:632
Definition bdlb_printmethods.h:283
BSLS_KEYWORD_CONSTEXPR bsl::add_const< TYPE >::type & as_const(TYPE &t) BSLS_KEYWORD_NOEXCEPT
return a reference offering non-modifiable access to the specified t.
Definition bslstl_utility.h:85
BloombergLP::bslmf::AddConst_Imp< t_TYPE,!is_reference< t_TYPE >::value &&!is_function< t_TYPE >::value &&!is_const< t_TYPE >::value >::Type type
Definition bslmf_addconst.h:172