Skip to content

Commit

Permalink
First round of C++20 fixes
Browse files Browse the repository at this point in the history
This patch does not attend to many new C++20 warnings, but
deals with new compilation failures, mostly arising from
an incomplete implementation and adoption of allocator
traits in our original C++11 port, and new errors using
narrow character iostreams with wchar_t data.  Most of the
changes affect test drivers only.
  • Loading branch information
AlisdairM committed Oct 12, 2020
1 parent 90fefbf commit 8b134f4
Show file tree
Hide file tree
Showing 38 changed files with 1,385 additions and 996 deletions.
8 changes: 4 additions & 4 deletions groups/bal/balber/balber_berutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -2328,14 +2328,14 @@ struct BerUtil_TimeImpUtil {
// PRIVATE TYPES
enum {
k_EXTENDED_BINARY_TIME_LENGTH =
DateAndTimeHeaderUtil::k_HEADER_LENGTH +
IntegerUtil::k_40_BIT_INTEGER_LENGTH, // = 7
+DateAndTimeHeaderUtil::k_HEADER_LENGTH +
+IntegerUtil::k_40_BIT_INTEGER_LENGTH, // = 7
// the number of content octets used by 'BerUtil' to encode
// a time value using the extended-binary time and time zone format

k_EXTENDED_BINARY_TIMETZ_LENGTH =
DateAndTimeHeaderUtil::k_HEADER_LENGTH +
IntegerUtil::k_40_BIT_INTEGER_LENGTH, // = 7
+DateAndTimeHeaderUtil::k_HEADER_LENGTH +
+IntegerUtil::k_40_BIT_INTEGER_LENGTH, // = 7
// the number of contents octets used by 'BerUtil' to encode
// a time and time zone value using the extended-binary time and
// time zone format
Expand Down
2 changes: 1 addition & 1 deletion groups/bal/balm/balm_stopwatchscopedguard.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ inline
StopwatchScopedGuard::~StopwatchScopedGuard()
{
if (isActive()) {
d_collector_p->update(d_stopwatch.elapsedTime() * d_timeUnits);
d_collector_p->update(d_stopwatch.elapsedTime() * +d_timeUnits);
}
}

Expand Down
2 changes: 1 addition & 1 deletion groups/bdl/bdlde/bdlde_charconvertutf16.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5973,7 +5973,7 @@ int main(int argc, char**argv)
cout << (char) w << endl;
}
else {
cout << w << endl;
cout << +w << endl;
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion groups/bdl/bdlde/bdlde_md5.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ BSLS_IDENT("$Id: $")
#include <bdlscm_version.h>

#include <bsls_alignedbuffer.h>
#include <bsls_compilerfeatures.h>
#include <bsls_types.h>

#include <bsl_cstring.h>
Expand Down Expand Up @@ -178,7 +179,9 @@ class Md5 {
// Destroy this MD5 digest.

// MANIPULATORS
// !Md5& operator=(const Md5& rhs);
#if defined(BSLS_COMPILERFEATURES_SUPPORT_DEFAULTED_FUNCTIONS)
Md5& operator=(const Md5& rhs) = default;
#endif
// Assign to this MD5 digest the value of the specified 'rhs' MD5
// digest and return a reference to this modifiable MD5 digest. Note
// that this method's definition is compiler generated.
Expand Down
56 changes: 28 additions & 28 deletions groups/bdl/bdlf/bdlf_bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -5013,36 +5013,36 @@ struct Bind_CalcParameterMask {
// be 0. For nested 'Bind' types, the out-of-range value 31 will be
// used.

, k_PARAM_MASK = Bind_ArgumentMask<Type1 >::k_VaL |
Bind_ArgumentMask<Type2 >::k_VaL |
Bind_ArgumentMask<Type3 >::k_VaL |
Bind_ArgumentMask<Type4 >::k_VaL |
Bind_ArgumentMask<Type5 >::k_VaL |
Bind_ArgumentMask<Type6 >::k_VaL |
Bind_ArgumentMask<Type7 >::k_VaL |
Bind_ArgumentMask<Type8 >::k_VaL |
Bind_ArgumentMask<Type9 >::k_VaL |
Bind_ArgumentMask<Type10>::k_VaL |
Bind_ArgumentMask<Type11>::k_VaL |
Bind_ArgumentMask<Type12>::k_VaL |
Bind_ArgumentMask<Type13>::k_VaL |
Bind_ArgumentMask<Type14>::k_VaL
, k_PARAM_MASK = +Bind_ArgumentMask<Type1 >::k_VaL |
+Bind_ArgumentMask<Type2 >::k_VaL |
+Bind_ArgumentMask<Type3 >::k_VaL |
+Bind_ArgumentMask<Type4 >::k_VaL |
+Bind_ArgumentMask<Type5 >::k_VaL |
+Bind_ArgumentMask<Type6 >::k_VaL |
+Bind_ArgumentMask<Type7 >::k_VaL |
+Bind_ArgumentMask<Type8 >::k_VaL |
+Bind_ArgumentMask<Type9 >::k_VaL |
+Bind_ArgumentMask<Type10>::k_VaL |
+Bind_ArgumentMask<Type11>::k_VaL |
+Bind_ArgumentMask<Type12>::k_VaL |
+Bind_ArgumentMask<Type13>::k_VaL |
+Bind_ArgumentMask<Type14>::k_VaL
// Mask of which parameters are place-holders.

, k_PARAM_MASK2 = Bind_ArgumentMask<Type1 >::k_VaL +
Bind_ArgumentMask<Type2 >::k_VaL +
Bind_ArgumentMask<Type3 >::k_VaL +
Bind_ArgumentMask<Type4 >::k_VaL +
Bind_ArgumentMask<Type5 >::k_VaL +
Bind_ArgumentMask<Type6 >::k_VaL +
Bind_ArgumentMask<Type7 >::k_VaL +
Bind_ArgumentMask<Type8 >::k_VaL +
Bind_ArgumentMask<Type9 >::k_VaL +
Bind_ArgumentMask<Type10>::k_VaL +
Bind_ArgumentMask<Type11>::k_VaL +
Bind_ArgumentMask<Type12>::k_VaL +
Bind_ArgumentMask<Type13>::k_VaL +
Bind_ArgumentMask<Type14>::k_VaL
, k_PARAM_MASK2 = +Bind_ArgumentMask<Type1 >::k_VaL +
+Bind_ArgumentMask<Type2 >::k_VaL +
+Bind_ArgumentMask<Type3 >::k_VaL +
+Bind_ArgumentMask<Type4 >::k_VaL +
+Bind_ArgumentMask<Type5 >::k_VaL +
+Bind_ArgumentMask<Type6 >::k_VaL +
+Bind_ArgumentMask<Type7 >::k_VaL +
+Bind_ArgumentMask<Type8 >::k_VaL +
+Bind_ArgumentMask<Type9 >::k_VaL +
+Bind_ArgumentMask<Type10>::k_VaL +
+Bind_ArgumentMask<Type11>::k_VaL +
+Bind_ArgumentMask<Type12>::k_VaL +
+Bind_ArgumentMask<Type13>::k_VaL +
+Bind_ArgumentMask<Type14>::k_VaL
// Mask of which parameters are place-holder calculated by addition
// rather the by ORing. If the given place-holder is used for multiple
// arguments, the result of mask will be different from the ORed value
Expand Down
2 changes: 1 addition & 1 deletion groups/bsl/bsl+bslhdrs/bsl_utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ BSLS_IDENT("$Id: $")

#include <bslmf_integersequence.h>
#include <bslmf_makeintegersequence.h>
#include <bslmf_matchanytype.h>
#include <bsls_libraryfeatures.h>
#include <bsls_nativestd.h>

Expand All @@ -39,7 +40,6 @@ namespace bsl {
#endif // BSL_OVERRIDES_STD

#ifdef BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY
using native_std::declval;
using native_std::forward;
using native_std::move;
using native_std::move_if_noexcept;
Expand Down
32 changes: 17 additions & 15 deletions groups/bsl/bslalg/bslalg_containerbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ BSLS_IDENT("$Id: $")
#include <bslscm_version.h>

#include <bslma_allocator.h>
#include <bslma_allocatortraits.h>

#include <bslmf_conditional.h>
#include <bslmf_isconvertible.h>
Expand Down Expand Up @@ -244,36 +245,37 @@ class ContainerBase : public
ContainerBase_BslmaBase<ALLOCATOR>,
ContainerBase_NonBslmaBase<ALLOCATOR> >::type Base;

public:
// PUBLIC TYPES
typedef typename Base::AllocatorType AllocatorType;
typedef bsl::allocator_traits<AllocatorType> AllocatorTraits;

typedef typename AllocatorTraits::size_type size_type;
typedef typename AllocatorTraits::difference_type difference_type;
typedef typename AllocatorTraits::pointer pointer;
typedef typename AllocatorTraits::const_pointer const_pointer;
typedef typename AllocatorTraits::value_type value_type;

// Restate required allocator types. (Reduces use of 'typename' in
// interface.)

private:
// NOT IMPLEMENTED
ContainerBase& operator=(const ContainerBase&);

private:
// PRIVATE MANIPULATORS
template <class T>
typename ALLOCATOR::template rebind<T>::other
typename AllocatorTraits::template rebind_alloc<T>
rebindAllocator(T*)
// Return 'this->allocator()' rebound for type 'T'. The 'T*' argument
// is used only for template parameter deduction and is ignored.
{
typedef typename ALLOCATOR::template rebind<T>::other Rebound;
typedef typename AllocatorTraits::template rebind_alloc<T> Rebound;
return Rebound(this->allocator());
}

public:
// PUBLIC TYPES
typedef typename Base::AllocatorType AllocatorType;

typedef typename AllocatorType::size_type size_type;
typedef typename AllocatorType::difference_type difference_type;
typedef typename AllocatorType::pointer pointer;
typedef typename AllocatorType::const_pointer const_pointer;
typedef typename AllocatorType::reference reference;
typedef typename AllocatorType::const_reference const_reference;
typedef typename AllocatorType::value_type value_type;
// Restate required allocator types. (Reduces use of 'typename' in
// interface.)

// CREATORS
ContainerBase(const ALLOCATOR& basicAllocator);
// Construct this object using the specified 'basicAllocator' of the
Expand Down
14 changes: 12 additions & 2 deletions groups/bsl/bslalg/bslalg_dequeprimitives.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ class TestTypeNoAlloc {
++numCharCtorCalls;
}

TestTypeNoAlloc(const TestTypeNoAlloc& original)
TestTypeNoAlloc(const TestTypeNoAlloc& original)
{
d_u.d_char = original.d_u.d_char;
++numCopyCtorCalls;
Expand Down Expand Up @@ -568,6 +568,11 @@ class BitwiseMoveableTestType : public TestType {
: TestType(original, ba)
{
}

#if defined(BSLS_COMPILERFEATURES_SUPPORT_DEFAULTED_FUNCTIONS)
BitwiseMoveableTestType&
operator=(const BitwiseMoveableTestType& other) = default;
#endif
};

// TRAITS
Expand Down Expand Up @@ -604,10 +609,15 @@ class BitwiseCopyableTestType : public TestTypeNoAlloc {
++numCharCtorCalls;
}

BitwiseCopyableTestType(const BitwiseCopyableTestType& original)
BitwiseCopyableTestType(const BitwiseCopyableTestType& original)
: TestTypeNoAlloc(original.datum())
{
}

#if defined(BSLS_COMPILERFEATURES_SUPPORT_DEFAULTED_FUNCTIONS)
BitwiseCopyableTestType&
operator=(const BitwiseCopyableTestType& other) = default;
#endif
};

// TRAITS
Expand Down
52 changes: 29 additions & 23 deletions groups/bsl/bslim/bslim_testutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,49 +148,51 @@ BSLS_IDENT("$Id: $")
#define BSLIM_TESTUTIL_ASSERT(X) \
aSsErT(!(X), #X, __LINE__);

#define BSLIM_TESTUTIL_DEBUG_REP(X) BloombergLP::bslim::TestUtil::debugRep(X)

#define BSLIM_TESTUTIL_LOOP0_ASSERT \
BSLIM_TESTUTIL_ASSERT

#define BSLIM_TESTUTIL_LOOP_ASSERT(I,X) \
if (!(X)) { bsl::cout << #I << ": " << (I) << "\n"; \
if (!(X)) { bsl::cout << #I << ": " << BSLIM_TESTUTIL_DEBUG_REP(I) << "\n";\
aSsErT(1, #X, __LINE__); }

#define BSLIM_TESTUTIL_LOOP1_ASSERT \
BSLIM_TESTUTIL_LOOP_ASSERT

#define BSLIM_TESTUTIL_LOOP2_ASSERT(I,J,X) \
if (!(X)) { bsl::cout << #I << ": " << (I) << "\t" \
<< #J << ": " << (J) << "\n"; \
if (!(X)) { bsl::cout << #I << ": " << BSLIM_TESTUTIL_DEBUG_REP(I) << "\t"\
<< #J << ": " << BSLIM_TESTUTIL_DEBUG_REP(J) << "\n";\
aSsErT(1, #X, __LINE__); }

#define BSLIM_TESTUTIL_LOOP3_ASSERT(I,J,K,X) \
if (!(X)) { bsl::cout << #I << ": " << (I) << "\t" \
<< #J << ": " << (J) << "\t" \
<< #K << ": " << (K) << "\n"; \
if (!(X)) { bsl::cout << #I << ": " << BSLIM_TESTUTIL_DEBUG_REP(I) << "\t"\
<< #J << ": " << BSLIM_TESTUTIL_DEBUG_REP(J) << "\t"\
<< #K << ": " << BSLIM_TESTUTIL_DEBUG_REP(K) << "\n";\
aSsErT(1, #X, __LINE__); }

#define BSLIM_TESTUTIL_LOOP4_ASSERT(I,J,K,L,X) \
if (!(X)) { bsl::cout << #I << ": " << (I) << "\t" \
<< #J << ": " << (J) << "\t" \
<< #K << ": " << (K) << "\t" \
<< #L << ": " << (L) << "\n"; \
if (!(X)) { bsl::cout << #I << ": " << BSLIM_TESTUTIL_DEBUG_REP(I) << "\t"\
<< #J << ": " << BSLIM_TESTUTIL_DEBUG_REP(J) << "\t"\
<< #K << ": " << BSLIM_TESTUTIL_DEBUG_REP(K) << "\t"\
<< #L << ": " << BSLIM_TESTUTIL_DEBUG_REP(L) << "\n";\
aSsErT(1, #X, __LINE__); }

#define BSLIM_TESTUTIL_LOOP5_ASSERT(I,J,K,L,M,X) \
if (!(X)) { bsl::cout << #I << ": " << (I) << "\t" \
<< #J << ": " << (J) << "\t" \
<< #K << ": " << (K) << "\t" \
<< #L << ": " << (L) << "\t" \
<< #M << ": " << (M) << "\n"; \
if (!(X)) { bsl::cout << #I << ": " << BSLIM_TESTUTIL_DEBUG_REP(I) << "\t"\
<< #J << ": " << BSLIM_TESTUTIL_DEBUG_REP(J) << "\t"\
<< #K << ": " << BSLIM_TESTUTIL_DEBUG_REP(K) << "\t"\
<< #L << ": " << BSLIM_TESTUTIL_DEBUG_REP(L) << "\t"\
<< #M << ": " << BSLIM_TESTUTIL_DEBUG_REP(M) << "\n";\
aSsErT(1, #X, __LINE__); }

#define BSLIM_TESTUTIL_LOOP6_ASSERT(I,J,K,L,M,N,X) \
if (!(X)) { bsl::cout << #I << ": " << (I) << "\t" \
<< #J << ": " << (J) << "\t" \
<< #K << ": " << (K) << "\t" \
<< #L << ": " << (L) << "\t" \
<< #M << ": " << (M) << "\t" \
<< #N << ": " << (N) << "\n"; \
if (!(X)) { bsl::cout << #I << ": " << BSLIM_TESTUTIL_DEBUG_REP(I) << "\t"\
<< #J << ": " << BSLIM_TESTUTIL_DEBUG_REP(J) << "\t"\
<< #K << ": " << BSLIM_TESTUTIL_DEBUG_REP(K) << "\t"\
<< #L << ": " << BSLIM_TESTUTIL_DEBUG_REP(L) << "\t"\
<< #M << ": " << BSLIM_TESTUTIL_DEBUG_REP(M) << "\t"\
<< #N << ": " << BSLIM_TESTUTIL_DEBUG_REP(N) << "\n";\
aSsErT(1, #X, __LINE__); }

// The 'BSLIM_TESTUTIL_EXPAND' macro is required to work around a preprocessor
Expand Down Expand Up @@ -222,11 +224,11 @@ BSLS_IDENT("$Id: $")
// Quote identifier literally.

#define BSLIM_TESTUTIL_P(X) \
bsl::cout << #X " = " << (X) << bsl::endl;
bsl::cout << #X " = " << BSLIM_TESTUTIL_DEBUG_REP(X) << bsl::endl;
// Print identifier and its value.

#define BSLIM_TESTUTIL_P_(X) \
bsl::cout << #X " = " << (X) << ", " << bsl::flush;
bsl::cout << #X " = " << BSLIM_TESTUTIL_DEBUG_REP(X) << ", " << bsl::flush;
// 'P(X)' without '\n'

#define BSLIM_TESTUTIL_L_ \
Expand Down Expand Up @@ -277,6 +279,10 @@ struct TestUtil {

static void setFunc(Func func);
// Set the function to be called by 'callFunc' to the specified 'func'.

template <class T>
static const T& debugRep(const T& arg) { return arg; }
static int debugRep(wchar_t arg) { return arg; }
};

} // close package namespace
Expand Down
7 changes: 6 additions & 1 deletion groups/bsl/bslma/bslma_allocatoradaptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,12 @@ class AllocatorAdaptor_Imp : public Allocator {
// Construct a polymorphic wrapper around a copy of the specified
// 'stla' STL-style allocator.

//! AllocatorAdaptor_Imp(const AllocatorAdaptor_Imp&);
#if defined(BSLS_COMPILERFEATURES_SUPPORT_DEFAULTED_FUNCTIONS)
AllocatorAdaptor_Imp(const AllocatorAdaptor_Imp& original) = default;
// Create an 'AllocatorAdaptor_Imp' object that can allocate and
// deallocate memory as if it were the specified 'original' object.
#endif


virtual ~AllocatorAdaptor_Imp();
// Destroy this object and the STL-style allocator that it wraps.
Expand Down

0 comments on commit 8b134f4

Please sign in to comment.