Skip to content

Commit

Permalink
master: bthread: get_started.cpp: std::vector<bool> may use bits to s…
Browse files Browse the repository at this point in the history
…tore values.
  • Loading branch information
bradbell committed Apr 4, 2024
1 parent 937bc81 commit d42e0e9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 8 additions & 0 deletions appendix/whats_new/2024.xrst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 7 additions & 3 deletions example/multi_thread/bthread/get_started.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@####@ , #####
@DEFAULT@ , USE_DEFAULT_ADFUN_CONSTRUCTOR
@Dir@ , bthread
}
}
{xrst_end bthread_get_started.cpp}
------------------------------------------------------------------------------
Expand All @@ -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<double> ) ad_vector;
typedef CPPAD_TESTVECTOR( CppAD::ADFun<double> ) fun_vector;
typedef CPPAD_TESTVECTOR( boost::thread* ) bthread_vector;
//
// std::vector<bool> 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<bool> b_vector;
//
// thread_specific_data_
void cleanup(size_t* thread_num)
{ delete thread_num;
Expand Down

0 comments on commit d42e0e9

Please sign in to comment.