Compare commits

..

1 Commits

Author SHA1 Message Date
René Ferdinand Rivera Morell
333c304d84 Add support for modular build structure. (#36)
* Make the library modular usable.

* Switch to library requirements instead of source. As source puts extra source in install targets.

* Add requires-b2 check to top-level build file.

* Bump B2 require to 5.2

* Change all <source> references to <library>.

* Update copyright dates.

* Move inter-lib dependencies to a project variable and into the build targets.

* Switch to /boost/test//included target for header only mode of Boost.Test.

* Update build deps.

* Add GHA CI with simpler working one based on alandefreitas/cpp-actions utilities.

* Move project global include to target local include.

* Only msvc gets minor version tests.

* Remove GHA CI to undo move to cpp-actions.
2025-06-26 02:51:42 +03:00
8 changed files with 85 additions and 53 deletions

30
build.jam Normal file
View File

@@ -0,0 +1,30 @@
# Copyright René Ferdinand Rivera Morell 2023-2024
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
require-b2 5.2 ;
constant boost_dependencies :
/boost/array//boost_array
/boost/assert//boost_assert
/boost/concept_check//boost_concept_check
/boost/config//boost_config
/boost/core//boost_core
/boost/functional//boost_functional
/boost/iterator//boost_iterator
/boost/mpl//boost_mpl
/boost/static_assert//boost_static_assert
/boost/type_traits//boost_type_traits ;
project /boost/multi_array
;
explicit
[ alias boost_multi_array : : :
: <include>include <library>$(boost_dependencies) ]
[ alias all : boost_multi_array test ]
;
call-if : boost-library multi_array
;

View File

@@ -158,7 +158,7 @@ public:
template <class ExtentList>
explicit multi_array(
ExtentList const& _extents,
ExtentList const& extents,
const Allocator& alloc = Allocator()
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
, typename mpl::if_<
@@ -166,7 +166,7 @@ public:
int&,int>::type* = 0
#endif
) :
super_type((T*)initial_base_,_extents),
super_type((T*)initial_base_,extents),
alloc_base(boost::empty_init_t(),alloc) {
boost::function_requires<
detail::multi_array::CollectionConcept<ExtentList> >();
@@ -175,9 +175,9 @@ public:
template <class ExtentList>
explicit multi_array(ExtentList const& _extents,
explicit multi_array(ExtentList const& extents,
const general_storage_order<NumDims>& so) :
super_type((T*)initial_base_,_extents,so),
super_type((T*)initial_base_,extents,so),
alloc_base(boost::empty_init_t()) {
boost::function_requires<
detail::multi_array::CollectionConcept<ExtentList> >();
@@ -185,10 +185,10 @@ public:
}
template <class ExtentList>
explicit multi_array(ExtentList const& _extents,
explicit multi_array(ExtentList const& extents,
const general_storage_order<NumDims>& so,
Allocator const& alloc) :
super_type((T*)initial_base_,_extents,so),
super_type((T*)initial_base_,extents,so),
alloc_base(boost::empty_init_t(),alloc) {
boost::function_requires<
detail::multi_array::CollectionConcept<ExtentList> >();
@@ -433,7 +433,7 @@ public:
template <typename ExtentList>
multi_array& resize(const ExtentList& _extents) {
multi_array& resize(const ExtentList& extents) {
boost::function_requires<
detail::multi_array::CollectionConcept<ExtentList> >();
@@ -442,7 +442,7 @@ public:
for (int i=0; i != NumDims; ++i) {
typedef typename gen_type::range range_type;
ranges.ranges_[i] = range_type(0,_extents[i]);
ranges.ranges_[i] = range_type(0,extents[i]);
}
return this->resize(ranges);

View File

@@ -128,15 +128,15 @@ protected:
// used by array operator[] and iterators to get reference types.
template <typename Reference, typename TPtr>
Reference access(boost::type<Reference>,index idx,TPtr base,
const size_type* _extents,
const size_type* extents,
const index* strides,
const index* index_bases) const {
BOOST_ASSERT(idx - index_bases[0] >= 0);
BOOST_ASSERT(size_type(idx - index_bases[0]) < _extents[0]);
BOOST_ASSERT(size_type(idx - index_bases[0]) < extents[0]);
// return a sub_array<T,NDims-1> proxy object
TPtr newbase = base + idx * strides[0];
return Reference(newbase,_extents+1,strides+1,index_bases+1);
return Reference(newbase,extents+1,strides+1,index_bases+1);
}
@@ -168,14 +168,14 @@ protected:
// used by array operator[] and iterators to get reference types.
template <typename Reference, typename TPtr>
Reference access(boost::type<Reference>,index idx,TPtr base,
const size_type* _extents,
const size_type* extents,
const index* strides,
const index* index_bases) const {
ignore_unused_variable_warning(index_bases);
ignore_unused_variable_warning(_extents);
ignore_unused_variable_warning(extents);
BOOST_ASSERT(idx - index_bases[0] >= 0);
BOOST_ASSERT(size_type(idx - index_bases[0]) < _extents[0]);
BOOST_ASSERT(size_type(idx - index_bases[0]) < extents[0]);
return *(base + idx * strides[0]);
}
@@ -299,17 +299,17 @@ protected:
Reference access_element(boost::type<Reference>,
const IndexList& indices,
TPtr base,
const size_type* _extents,
const size_type* extents,
const index* strides,
const index* index_bases) const {
boost::function_requires<
CollectionConcept<IndexList> >();
ignore_unused_variable_warning(index_bases);
ignore_unused_variable_warning(_extents);
ignore_unused_variable_warning(extents);
#if !defined(NDEBUG) && !defined(BOOST_DISABLE_ASSERTS)
for (size_type i = 0; i != NumDims; ++i) {
BOOST_ASSERT(indices[i] - index_bases[i] >= 0);
BOOST_ASSERT(size_type(indices[i] - index_bases[i]) < _extents[i]);
BOOST_ASSERT(size_type(indices[i] - index_bases[i]) < extents[i]);
}
#endif
@@ -408,7 +408,7 @@ protected:
generate_array_view(boost::type<ArrayRef>,
const boost::detail::multi_array::
index_gen<NumDims,NDims>& indices,
const size_type* _extents,
const size_type* extents,
const index* strides,
const index* index_bases,
TPtr base) const {
@@ -422,7 +422,7 @@ protected:
// Use array specs and input specs to produce real specs.
const index default_start = index_bases[n];
const index default_finish = default_start+_extents[n];
const index default_finish = default_start+extents[n];
const index_range& current_range = indices.ranges_[n];
index start = current_range.get_start(default_start);
index finish = current_range.get_finish(default_finish);
@@ -453,8 +453,8 @@ protected:
// exactly in the set of legal indices
// with a special case for empty arrays
BOOST_ASSERT(index_bases[n] <= start &&
((start <= index_bases[n]+index(_extents[n])) ||
(start == index_bases[n] && _extents[n] == 0)));
((start <= index_bases[n]+index(extents[n])) ||
(start == index_bases[n] && extents[n] == 0)));
#ifndef BOOST_DISABLE_ASSERTS
// finish marks the open side of the range, so it can go one past
@@ -462,7 +462,7 @@ protected:
// if stride is negative).
index bound_adjustment = stride < 0 ? 1 : 0;
BOOST_ASSERT(((index_bases[n] - bound_adjustment) <= finish) &&
(finish <= (index_bases[n] + index(_extents[n]) - bound_adjustment)));
(finish <= (index_bases[n] + index(extents[n]) - bound_adjustment)));
ignore_unused_variable_warning(bound_adjustment);
#endif // BOOST_DISABLE_ASSERTS

View File

@@ -94,10 +94,10 @@ public:
array_iterator() {}
array_iterator(index idx, TPtr base, const size_type* _extents,
array_iterator(index idx, TPtr base, const size_type* extents,
const index* strides,
const index* index_base) :
idx_(idx), base_(base), extents_(_extents),
idx_(idx), base_(base), extents_(extents),
strides_(strides), index_base_(index_base) { }
template <typename OPtr, typename ORef, typename Cat>

View File

@@ -87,24 +87,24 @@ public:
num_elements_(other.num_elements_) { }
template <typename ExtentList>
explicit const_multi_array_ref(TPtr base, const ExtentList& _extents) :
explicit const_multi_array_ref(TPtr base, const ExtentList& extents) :
base_(base), storage_(c_storage_order()) {
boost::function_requires<
CollectionConcept<ExtentList> >();
index_base_list_.assign(0);
init_multi_array_ref(_extents.begin());
init_multi_array_ref(extents.begin());
}
template <typename ExtentList>
explicit const_multi_array_ref(TPtr base, const ExtentList& _extents,
explicit const_multi_array_ref(TPtr base, const ExtentList& extents,
const general_storage_order<NumDims>& so) :
base_(base), storage_(so) {
boost::function_requires<
CollectionConcept<ExtentList> >();
index_base_list_.assign(0);
init_multi_array_ref(_extents.begin());
init_multi_array_ref(extents.begin());
}
explicit const_multi_array_ref(TPtr base,
@@ -162,14 +162,14 @@ public:
}
template <typename SizeList>
void reshape(const SizeList& _extents) {
void reshape(const SizeList& extents) {
boost::function_requires<
CollectionConcept<SizeList> >();
BOOST_ASSERT(num_elements_ ==
std::accumulate(_extents.begin(),_extents.end(),
std::accumulate(extents.begin(),extents.end(),
size_type(1),std::multiplies<size_type>()));
std::copy(_extents.begin(),_extents.end(),extent_list_.begin());
std::copy(extents.begin(),extents.end(),extent_list_.begin());
this->compute_strides(stride_list_,extent_list_,storage_);
origin_offset_ =
@@ -325,7 +325,7 @@ public:
const_multi_array_ref(TPtr base,
const storage_order_type& so,
const index * index_bases,
const size_type* _extents) :
const size_type* extents) :
base_(base), storage_(so), origin_offset_(0), directional_offset_(0)
{
// If index_bases or extents is null, then initialize the corresponding
@@ -336,8 +336,8 @@ public:
} else {
std::fill_n(index_base_list_.begin(),NumDims,0);
}
if(_extents) {
init_multi_array_ref(_extents);
if(extents) {
init_multi_array_ref(extents);
} else {
boost::array<index,NumDims> extent_list;
extent_list.assign(0);
@@ -371,12 +371,12 @@ private:
boost::mem_fun_ref(&extent_range::start));
// calculate the extents
extent_list _extents;
extent_list extents;
std::transform(ranges.ranges_.begin(),ranges.ranges_.end(),
_extents.begin(),
extents.begin(),
boost::mem_fun_ref(&extent_range::size));
init_multi_array_ref(_extents.begin());
init_multi_array_ref(extents.begin());
}
@@ -442,16 +442,16 @@ public:
};
template <class ExtentList>
explicit multi_array_ref(T* base, const ExtentList& _extents) :
super_type(base,_extents) {
explicit multi_array_ref(T* base, const ExtentList& extents) :
super_type(base,extents) {
boost::function_requires<
CollectionConcept<ExtentList> >();
}
template <class ExtentList>
explicit multi_array_ref(T* base, const ExtentList& _extents,
explicit multi_array_ref(T* base, const ExtentList& extents,
const general_storage_order<NumDims>& so) :
super_type(base,_extents,so) {
super_type(base,extents,so) {
boost::function_requires<
CollectionConcept<ExtentList> >();
}
@@ -612,8 +612,8 @@ protected:
explicit multi_array_ref(T* base,
const storage_order_type& so,
const index* index_bases,
const size_type* _extents) :
super_type(base,so,index_bases,_extents) { }
const size_type* extents) :
super_type(base,so,index_bases,extents) { }
};

View File

@@ -176,10 +176,10 @@ public: // Should be protected
#endif
const_sub_array (TPtr base,
const size_type* _extents,
const size_type* extents,
const index* strides,
const index* index_base) :
base_(base), extents_(_extents), strides_(strides),
base_(base), extents_(extents), strides_(strides),
index_base_(index_base) {
}
@@ -356,10 +356,10 @@ public: // should be private
#endif
sub_array (T* base,
const size_type* _extents,
const size_type* extents,
const index* strides,
const index* index_base) :
super_type(base,_extents,strides,index_base) {
super_type(base,extents,strides,index_base) {
}
};

View File

@@ -227,7 +227,7 @@ public: // should be protected
// to create strides
template <typename ExtentList, typename Index>
explicit const_multi_array_view(TPtr base,
const ExtentList& _extents,
const ExtentList& extents,
const boost::array<Index,NumDims>& strides):
base_(base), origin_offset_(0) {
@@ -235,7 +235,7 @@ public: // should be protected
// Get the extents and strides
boost::detail::multi_array::
copy_n(_extents.begin(),NumDims,extent_list_.begin());
copy_n(extents.begin(),NumDims,extent_list_.begin());
boost::detail::multi_array::
copy_n(strides.begin(),NumDims,stride_list_.begin());
@@ -429,9 +429,9 @@ public: // should be private
// generate array views
template <typename ExtentList, typename Index>
explicit multi_array_view(T* base,
const ExtentList& _extents,
const ExtentList& extents,
const boost::array<Index,NumDims>& strides) :
super_type(base,_extents,strides) { }
super_type(base,extents,strides) { }
};

View File

@@ -6,6 +6,8 @@
import testing ;
project : requirements <library>/boost/multi_array//boost_multi_array ;
compile-fail fail_cbracket.cpp ;
compile-fail fail_cdata.cpp ;
compile-fail fail_citerator.cpp ;
@@ -15,7 +17,7 @@ compile-fail fail_csubarray.cpp ;
compile-fail fail_csubarray2.cpp ;
compile-fail fail_csubarray3.cpp ;
compile-fail fail_cview.cpp ;
compile-fail fail_cview2.cpp ;
compile-fail fail_cview2.cpp : <library>/boost/test//included ;
compile-fail fail_cview3.cpp ;
compile-fail fail_ref_cbracket.cpp ;
compile-fail fail_ref_cdata.cpp ;
@@ -28,7 +30,7 @@ compile-fail fail_ref_csubarray3.cpp ;
compile-fail fail_ref_cview.cpp ;
compile-fail fail_ref_cview2.cpp ;
compile-fail fail_ref_cview3.cpp ;
run constructors.cpp ;
run access.cpp ;
run compare.cpp ;