Skip to content

Commit

Permalink
Moving more code from boost to std (#105)
Browse files Browse the repository at this point in the history
* Moving more code from boost to std

including: array, any, integer types, filesystem, some type_traits style functions, static_assert, function objects
Also replaced platform dependent time code with std::chrono
Also removed a custom optional type and replaced it with std::optional
Also removed references to tr1
Also removed old metrowerks code guards

* fixing build

* applying suggested changes

---------

Co-authored-by: Bryn Aspestrand <aspestra@adobe.com>
  • Loading branch information
thinlang and Bryn Aspestrand authored Dec 20, 2023
1 parent e858047 commit bb6bb09
Show file tree
Hide file tree
Showing 67 changed files with 295 additions and 536 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ else()
endif()

function(target_link_boost target)
target_link_libraries(${target} PUBLIC Boost::system Boost::filesystem)
target_link_libraries(${target} PUBLIC Boost::system)
endfunction(target_link_boost)

function(target_link_boost_test target)
Expand All @@ -85,7 +85,7 @@ function(target_link_boost_test target)
endfunction(target_link_boost_test)

message("ASL_INFO: Using system boost.")
set(ASL_BOOST_COMPONENTS system filesystem unit_test_framework program_options)
set(ASL_BOOST_COMPONENTS system unit_test_framework program_options)
find_package(Boost COMPONENTS ${ASL_BOOST_COMPONENTS} REQUIRED)

add_subdirectory(source)
Expand Down
20 changes: 4 additions & 16 deletions adobe/adam.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,8 @@
#include <functional>
#include <vector>

#include <boost/function.hpp>

#ifdef __MWERKS__
#pragma warn_unusedarg off
#pragma warn_unusedvar off
#endif

#include <boost/signals2/signal.hpp>

#ifdef __MWERKS__
#pragma warn_unusedarg reset
#pragma warn_unusedvar reset
#endif

#include <adobe/any_regular_fwd.hpp>
#include <adobe/array.hpp>
#include <adobe/dictionary_fwd.hpp>
Expand Down Expand Up @@ -68,10 +56,10 @@ class sheet_t : boost::noncopyable {
public:
struct relation_t;

typedef boost::function<void(bool)> monitor_invariant_t;
typedef boost::function<void(const any_regular_t&)> monitor_value_t;
typedef boost::function<void(const dictionary_t&)> monitor_contributing_t;
typedef boost::function<void(bool)> monitor_enabled_t;
using monitor_invariant_t = std::function<void(bool)>;
using monitor_value_t = std::function<void(const any_regular_t&)>;
using monitor_contributing_t = std::function<void(const dictionary_t&)>;
using monitor_enabled_t = std::function<void(bool)>;

/*!
Expand Down
40 changes: 18 additions & 22 deletions adobe/adam_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@

#include <adobe/config.hpp>

#include <functional>
#include <iosfwd>
#include <string>
#include <vector>

#include <boost/function.hpp>

#include <adobe/array.hpp>
#include <adobe/istream.hpp>
#include <adobe/string.hpp>
Expand Down Expand Up @@ -146,26 +145,23 @@ struct adam_callback_suite_t {
std::string brief_m;
};

typedef boost::function<void(cell_type_t type, name_t cell_name,
const line_position_t& position, const array_t& expr_or_init,
const std::string& brief, const std::string& detailed)>
add_cell_proc_t;

typedef boost::function<void(const line_position_t& position, const array_t& conditional,
const relation_t* first, const relation_t* last,
const std::string& brief,
const std::string& detailed)>
add_relation_proc_t; // REVISIT (sparent) where's brief?

typedef boost::function<void(name_t cell_name, bool linked, const line_position_t& position1,
const array_t& initializer, const line_position_t& position2,
const array_t& expression, const std::string& brief,
const std::string& detailed)>
add_interface_proc_t;

typedef boost::function<void(name_t cell_name, const line_position_t& position,
const std::string& brief, const std::string& detailed)>
add_external_proc_t;
using add_cell_proc_t = std::function<void(
cell_type_t type, name_t cell_name, const line_position_t& position,
const array_t& expr_or_init, const std::string& brief, const std::string& detailed)>;

using add_relation_proc_t = std::function<void(
const line_position_t& position, const array_t& conditional, const relation_t* first,
const relation_t* last, const std::string& brief,
const std::string& detailed)>; // REVISIT (sparent) where's brief?

using add_interface_proc_t = std::function<void(
name_t cell_name, bool linked, const line_position_t& position1, const array_t& initializer,
const line_position_t& position2, const array_t& expression, const std::string& brief,
const std::string& detailed)>;

using add_external_proc_t = std::function<void(
name_t cell_name, const line_position_t& position,
const std::string& brief, const std::string& detailed)>;

add_cell_proc_t add_cell_proc_m;
add_relation_proc_t add_relation_proc_m;
Expand Down
5 changes: 3 additions & 2 deletions adobe/algorithm/binary_search.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <adobe/config.hpp>

#include <functional>
#include <type_traits>

#include <boost/range/begin.hpp>
#include <boost/range/const_iterator.hpp>
Expand Down Expand Up @@ -147,7 +148,7 @@ template <typename I, // I models ForwardRange
typename T, // T == result_type(P)
typename C, // C models StrictWeakOrdering(T, T)
typename P> // P models UnaryFunction(value_type(I)) -> T
inline typename boost::lazy_disable_if<boost::is_same<I, T>, boost::range_iterator<I>>::type
inline typename boost::lazy_disable_if<std::is_same<I, T>, boost::range_iterator<I>>::type
binary_search(I& r, const T& x, C c, P p) {
return adobe::binary_search(boost::begin(r), boost::end(r), x, c, p);
}
Expand All @@ -158,7 +159,7 @@ template <typename I, // I models ForwardRange
typename T, // T == result_type(P)
typename C, // C models StrictWeakOrdering(T, T)
typename P> // P models UnaryFunction(value_type(I)) -> T
inline typename boost::lazy_disable_if<boost::is_same<I, T>, boost::range_const_iterator<I>>::type
inline typename boost::lazy_disable_if<std::is_same<I, T>, boost::range_const_iterator<I>>::type
binary_search(const I& r, const T& x, C c, P p) {
return adobe::binary_search(boost::begin(r), boost::end(r), x, c, p);
}
Expand Down
9 changes: 5 additions & 4 deletions adobe/algorithm/equal_range.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <algorithm>
#include <cassert>
#include <functional>
#include <type_traits>
#include <utility>

#include <boost/next_prior.hpp>
Expand Down Expand Up @@ -189,7 +190,7 @@ template <typename I, // I models ForwardRange
typename T, // T == result_type(P)
typename C, // C models StrictWeakOrdering(T, T)
typename P> // P models UnaryFunction(value_type(I)) -> T
inline typename boost::lazy_disable_if<boost::is_same<I, T>, implementation::lazy_range<I>>::type
inline typename boost::lazy_disable_if<std::is_same<I, T>, implementation::lazy_range<I>>::type
equal_range(I& r, const T& x, C c, P p) {
return adobe::equal_range(boost::begin(r), boost::end(r), x, c, p);
}
Expand All @@ -205,7 +206,7 @@ template <typename I, // I models ForwardRange
typename C, // C models StrictWeakOrdering(T, T)
typename P> // P models UnaryFunction(value_type(I)) -> T
inline
typename boost::lazy_disable_if<boost::is_same<I, T>, implementation::lazy_range_const<I>>::type
typename boost::lazy_disable_if<std::is_same<I, T>, implementation::lazy_range_const<I>>::type
equal_range(const I& r, const T& x, C c, P p) {
return adobe::equal_range(boost::begin(r), boost::end(r), x, c, p);
}
Expand Down Expand Up @@ -246,7 +247,7 @@ equal_range(const I& r, const T& x) {
template <typename I, // I models ForwardRange
typename T, // T == result_type(P)
typename C> // C models StrictWeakOrdering(T, T)
inline typename boost::lazy_disable_if<boost::is_same<I, T>, implementation::lazy_range<I>>::type
inline typename boost::lazy_disable_if<std::is_same<I, T>, implementation::lazy_range<I>>::type
equal_range(I& r, const T& x, C c) {
return adobe::equal_range(boost::begin(r), boost::end(r), x, c);
}
Expand All @@ -261,7 +262,7 @@ template <typename I, // I models ForwardRange
typename T, // T == result_type(P)
typename C> // C models StrictWeakOrdering(T, T)
inline
typename boost::lazy_disable_if<boost::is_same<I, T>, implementation::lazy_range_const<I>>::type
typename boost::lazy_disable_if<std::is_same<I, T>, implementation::lazy_range_const<I>>::type
equal_range(const I& r, const T& x, C c) {
return adobe::equal_range(boost::begin(r), boost::end(r), x, c);
}
Expand Down
10 changes: 5 additions & 5 deletions adobe/algorithm/lower_bound.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
#include <algorithm>
#include <functional>
#include <iterator>
#include <type_traits>

#include <boost/next_prior.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/utility/enable_if.hpp>

#include <adobe/functional/operator.hpp>
Expand Down Expand Up @@ -148,7 +148,7 @@ template <typename I, // I models ForwardRange
typename T, // T == result_type(P)
typename C, // C models StrictWeakOrdering(T, T)
typename P> // P models UnaryFunction(value_type(I)) -> T
inline typename boost::lazy_disable_if<boost::is_same<I, T>, boost::range_iterator<I>>::type
inline typename boost::lazy_disable_if<std::is_same<I, T>, boost::range_iterator<I>>::type
lower_bound(I& r, const T& x, C c, P p) {
return adobe::lower_bound(boost::begin(r), boost::end(r), x, c, p);
}
Expand All @@ -159,7 +159,7 @@ template <typename I, // I models ForwardRange
typename T, // T == result_type(P)
typename C, // C models StrictWeakOrdering(T, T)
typename P> // P models UnaryFunction(value_type(I)) -> T
inline typename boost::lazy_disable_if<boost::is_same<I, T>, boost::range_const_iterator<I>>::type
inline typename boost::lazy_disable_if<std::is_same<I, T>, boost::range_const_iterator<I>>::type
lower_bound(const I& r, const T& x, C c, P p) {
return adobe::lower_bound(boost::begin(r), boost::end(r), x, c, p);
}
Expand Down Expand Up @@ -198,7 +198,7 @@ lower_bound(const ForwardRange& range, const T& value) {
\brief lower_bound implementation
*/
template <typename I, class T, class Compare>
inline typename boost::lazy_disable_if<boost::is_same<I, T>, boost::range_iterator<I>>::type
inline typename boost::lazy_disable_if<std::is_same<I, T>, boost::range_iterator<I>>::type
lower_bound(I& range, const T& value, Compare comp) {
return adobe::lower_bound(boost::begin(range), boost::end(range), value, comp);
}
Expand All @@ -209,7 +209,7 @@ lower_bound(I& range, const T& value, Compare comp) {
\brief lower_bound implementation
*/
template <class I, class T, class Compare>
inline typename boost::lazy_disable_if<boost::is_same<I, T>, boost::range_const_iterator<I>>::type
inline typename boost::lazy_disable_if<std::is_same<I, T>, boost::range_const_iterator<I>>::type
lower_bound(const I& range, const T& value, Compare comp) {
return adobe::lower_bound(boost::begin(range), boost::end(range), value, comp);
}
Expand Down
10 changes: 5 additions & 5 deletions adobe/algorithm/upper_bound.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
#include <cassert>
#include <functional>
#include <iterator>
#include <type_traits>

#include <boost/next_prior.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/utility/enable_if.hpp>

#include <adobe/functional.hpp>
Expand Down Expand Up @@ -152,7 +152,7 @@ template <typename I, // I models ForwardRange
typename T, // T == result_type(P)
typename C, // C models StrictWeakOrdering(T, T)
typename P> // P models UnaryFunction(value_type(I)) -> T
inline typename boost::lazy_disable_if<boost::is_same<I, T>, boost::range_iterator<I>>::type
inline typename boost::lazy_disable_if<std::is_same<I, T>, boost::range_iterator<I>>::type
upper_bound(I& r, const T& x, C c, P p) {
return adobe::upper_bound(boost::begin(r), boost::end(r), x, c, p);
}
Expand All @@ -163,7 +163,7 @@ template <typename I, // I models ForwardRange
typename T, // T == result_type(P)
typename C, // C models StrictWeakOrdering(T, T)
typename P> // P models UnaryFunction(value_type(I)) -> T
inline typename boost::lazy_disable_if<boost::is_same<I, T>, boost::range_const_iterator<I>>::type
inline typename boost::lazy_disable_if<std::is_same<I, T>, boost::range_const_iterator<I>>::type
upper_bound(const I& r, const T& x, C c, P p) {
return adobe::upper_bound(boost::begin(r), boost::end(r), x, c, p);
}
Expand Down Expand Up @@ -202,7 +202,7 @@ upper_bound(const ForwardRange& range, const T& value) {
\brief upper_bound implementation
*/
template <typename I, class T, class Compare>
inline typename boost::lazy_disable_if<boost::is_same<I, T>, boost::range_iterator<I>>::type
inline typename boost::lazy_disable_if<std::is_same<I, T>, boost::range_iterator<I>>::type
upper_bound(I& range, const T& value, Compare comp) {
return adobe::upper_bound(boost::begin(range), boost::end(range), value, comp);
}
Expand All @@ -213,7 +213,7 @@ upper_bound(I& range, const T& value, Compare comp) {
\brief upper_bound implementation
*/
template <class I, class T, class Compare>
inline typename boost::lazy_disable_if<boost::is_same<I, T>, boost::range_const_iterator<I>>::type
inline typename boost::lazy_disable_if<std::is_same<I, T>, boost::range_const_iterator<I>>::type
upper_bound(const I& range, const T& value, Compare comp) {
return adobe::upper_bound(boost::begin(range), boost::end(range), value, comp);
}
Expand Down
Loading

0 comments on commit bb6bb09

Please sign in to comment.