From d42e0e94a3a81cf468fc48c5ef2bfd132aa9f093 Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Thu, 4 Apr 2024 06:04:13 -0700 Subject: [PATCH] master: bthread: get_started.cpp: std::vector may use bits to store values. --- appendix/whats_new/2024.xrst | 8 ++++++++ example/multi_thread/bthread/get_started.cpp | 10 +++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/appendix/whats_new/2024.xrst b/appendix/whats_new/2024.xrst index f34fe219b..e4d923e16 100644 --- a/appendix/whats_new/2024.xrst +++ b/appendix/whats_new/2024.xrst @@ -28,6 +28,14 @@ Release Notes for 2024 mm-dd ***** +04-04 +===== +The file example/multi_thread/bthread/get_started.cpp had an error +when ``CPPAD_TESTVECTOR`` was :ref:`testvector@std::vector` +(The elements of a standard vectors of bool may a single bits instead of +a boolean value). +The has been fixed. + 04-03 ===== #. Add the :ref:`valvector_llsq_obj.cpp-name` example. diff --git a/example/multi_thread/bthread/get_started.cpp b/example/multi_thread/bthread/get_started.cpp index 1e912f959..1a8067154 100644 --- a/example/multi_thread/bthread/get_started.cpp +++ b/example/multi_thread/bthread/get_started.cpp @@ -11,7 +11,7 @@ @####@ , ##### @DEFAULT@ , USE_DEFAULT_ADFUN_CONSTRUCTOR @Dir@ , bthread -} +} {xrst_end bthread_get_started.cpp} ------------------------------------------------------------------------------ @@ -24,13 +24,17 @@ namespace { // - // b_vector, d_vector, ad_vector, fun_vector - typedef CPPAD_TESTVECTOR(bool) b_vector; + // d_vector, ad_vector, fun_vector typedef CPPAD_TESTVECTOR(double) d_vector; typedef CPPAD_TESTVECTOR( CppAD::AD ) ad_vector; typedef CPPAD_TESTVECTOR( CppAD::ADFun ) fun_vector; typedef CPPAD_TESTVECTOR( boost::thread* ) bthread_vector; // + // std::vector does not support the data method; see + // https://en.cppreference.com/w/cpp/container/vector_bool + // 'Does not necessarily store its elements as a contiguous array.' + typedef CppAD::vector b_vector; + // // thread_specific_data_ void cleanup(size_t* thread_num) { delete thread_num;