Skip to content

Commit

Permalink
drop dependency on boost.detail
Browse files Browse the repository at this point in the history
  • Loading branch information
akrzemi1 committed Jan 3, 2024
1 parent a1dbd3b commit 01e80d2
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 257 deletions.
25 changes: 12 additions & 13 deletions doc/90_dependencies.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ The implementation uses the following other Boost modules:
# assert
# config
# core
# detail
# move
# mpl
# static_assert
Expand All @@ -34,15 +33,15 @@ Certain constructors and functions in the interface of `optional` perform a 'per
template<class... Args> optional(in_place_init_t, Args&&... args);
template<class... Args> optional(in_place_init_if_t, bool condition, Args&&... args);
template<class... Args> void emplace(Args&&... args);

On compilers that do not support variadic templates, each of these functions is substituted with two overloads, one forwarding a single argument, the other forwarding zero arguments. This forms the following set:

template<class Arg> optional(in_place_init_t, Arg&& arg);
optional(in_place_init_t);

template<class Arg> optional(in_place_init_if_t, bool condition, Arg&& arg);
optional(in_place_init_if_t, bool condition);

template<class Arg> void emplace(Arg&& arg);
void emplace();

Expand All @@ -51,16 +50,16 @@ On compilers that do not support rvalue references, each of these functions is s
template<class Arg> optional(in_place_init_t, const Arg& arg);
template<class Arg> optional(in_place_init_t, Arg& arg);
optional(in_place_init_t);

template<class Arg> optional(in_place_init_if_t, bool condition, const Arg& arg);
template<class Arg> optional(in_place_init_if_t, bool condition, Arg& arg);
optional(in_place_init_if_t, bool condition);

template<class Arg> void emplace(const Arg& arg);
template<class Arg> void emplace(Arg& arg);
void emplace();

This workaround addresses about 40% of all use cases. If this is insufficient, you need to resort to using [link boost_optional.tutorial.in_place_factories In-Place Factories].
This workaround addresses about 40% of all use cases. If this is insufficient, you need to resort to using [link boost_optional.tutorial.in_place_factories In-Place Factories].
[endsect]

[section Optional Reference Binding][#optional_reference_binding]
Expand All @@ -71,11 +70,11 @@ A number of compilers incorrectly treat const lvalues of integral type as rvalue
optional<const int&> or1;
optional<const int&> or2 = i; // caution: not portable
or1 = i; // caution: not portable

optional<const int&> or3(i); // portable
or1 = optional<const int&>(i); // portable

Compilers known to have these deficiencies include GCC versions 4.2, 4.3, 4.4, 4.5, 5.1, 5.2; QCC 4.4.2; MSVC versions 8.0, 9.0, 10.0, 11.0, 12.0. In order to check if your compiler correctly implements reference binding use this test program.
Compilers known to have these deficiencies include GCC versions 4.2, 4.3, 4.4, 4.5, 5.1, 5.2; QCC 4.4.2; MSVC versions 8.0, 9.0, 10.0, 11.0, 12.0. In order to check if your compiler correctly implements reference binding use this test program.

#include <cassert>

Expand All @@ -88,13 +87,13 @@ Compilers known to have these deficiencies include GCC versions 4.2, 4.3, 4.4, 4
assert(&ii == &global_i);
}

void operator=(const int& ii)
void operator=(const int& ii)
{
assert(&ii == &global_i);
}

void operator=(int&&) // remove this if your compiler doesn't have rvalue refs
{
{
assert(false);
}
};
Expand All @@ -110,7 +109,7 @@ Compilers known to have these deficiencies include GCC versions 4.2, 4.3, 4.4, 4
TestingReferenceBinding ttt2 = iref;
ttt2 = iref;
}

[endsect]

[endsect]
[endsect]
1 change: 1 addition & 0 deletions doc/91_relnotes.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

* Fixed the implementation for trivial types. Now it is slower, because it always initializes the `T`, but it avoids undefined behavior when `optional<T>` is copied. This fixes [@https://github.com/boostorg/optional/issues/108 issue #108].
* Fixed some `-Wmaybe-uninitialized` warnings in GCC 12. Thanks to Christian Mazakas for the fix.
* Dropped dependency on Boost.Detail.

[heading Boost Release 1.83]

Expand Down
14 changes: 7 additions & 7 deletions include/boost/optional/detail/experimental_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
#define BOOST_OPTIONAL_DETAIL_EXPERIMENTAL_TRAITS_04NOV2017_HPP

#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/config/workaround.hpp>
#include <boost/predef.h>
#include <boost/type_traits.hpp>

// The condition to use POD implementation

#ifdef BOOST_OPTIONAL_CONFIG_NO_POD_SPEC
Expand Down Expand Up @@ -50,7 +50,7 @@
# define BOOST_OPTIONAL_DETAIL_USE_STD_TYPE_TRAITS
# endif
# endif
#endif
#endif


#ifndef BOOST_OPTIONAL_DETAIL_USE_STD_TYPE_TRAITS
Expand All @@ -59,10 +59,10 @@
# include <type_traits>
# define BOOST_OPTIONAL_DETAIL_HAS_TRIVIAL_CTOR(T) std::is_trivially_default_constructible<T>::value
#endif


namespace boost { namespace optional_detail {

#ifndef BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
template <typename T>
struct is_type_trivially_copyable
Expand All @@ -83,7 +83,7 @@ struct is_type_trivially_copyable



#ifndef BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
#ifndef BOOST_OPTIONAL_DETAIL_NO_SPEC_FOR_TRIVIAL_TYPES
template <typename T>
struct optional_uses_direct_storage_for_
: boost::conditional< (is_type_trivially_copyable<T>::value && BOOST_OPTIONAL_DETAIL_HAS_TRIVIAL_CTOR(T)) ||
Expand Down
4 changes: 2 additions & 2 deletions include/boost/optional/detail/optional_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#define BOOST_OPTIONAL_DETAIL_OPTIONAL_CONFIG_AJK_28JAN2015_HPP

#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/config/workaround.hpp>

#if (defined BOOST_NO_CXX11_RVALUE_REFERENCES) || (defined BOOST_OPTIONAL_CONFIG_NO_RVALUE_REFERENCES)
# define BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
Expand Down Expand Up @@ -55,7 +55,7 @@
#if (defined(_MSC_VER) && _MSC_VER <= 1800)
// on MSVC 2013 and earlier an unwanted temporary is created when you assign from
// a const lvalue of integral type. Thus we bind not to the original address but
// to a temporary.
// to a temporary.
# define BOOST_OPTIONAL_CONFIG_NO_PROPER_ASSIGN_FROM_CONST_INT
#endif

Expand Down
8 changes: 0 additions & 8 deletions include/boost/optional/optional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ struct optional_value_type< ::boost::optional<T> >

}} // namespace boost::optional_detail

#ifdef BOOST_OPTIONAL_CONFIG_USE_OLD_IMPLEMENTATION_OF_OPTIONAL
#include <boost/optional/detail/old_optional_implementation.hpp>
#else
namespace boost {

namespace optional_ns {
Expand Down Expand Up @@ -1513,11 +1510,6 @@ class optional
BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()
} ;

} // namespace boost

#endif // BOOST_OPTIONAL_CONFIG_USE_OLD_IMPLEMENTATION_OF_OPTIONAL

namespace boost {

#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
template<class T>
Expand Down
1 change: 0 additions & 1 deletion test/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import testing ;
[ run optional_test_io.cpp ]
[ run optional_test_move.cpp ]
[ run optional_test_noexcept_move.cpp ]
[ run optional_test_old_impl.cpp ]
[ run optional_test_equals_none.cpp ]
[ run optional_test_value_access.cpp ]
[ run optional_test_emplace.cpp ]
Expand Down
3 changes: 3 additions & 0 deletions test/optional_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,8 @@ struct VBase : virtual X
VBase(int v) : X(v) {}
// MSVC 8.0 doesn't generate this correctly...
VBase(const VBase& other) : X(static_cast<const X&>(other)) {}

VBase& operator=(VBase const& rhs) { X::operator=(rhs); return *this; }
};

void test_with_class_type()
Expand Down Expand Up @@ -917,6 +919,7 @@ class CustomAddressOfClass
public:
CustomAddressOfClass() : n(0) {}
CustomAddressOfClass(CustomAddressOfClass const& that) : n(that.n) {}
CustomAddressOfClass& operator=(CustomAddressOfClass const& rhs) { n = rhs.n; return *this; }
explicit CustomAddressOfClass(int m) : n(m) {}
int* operator& () { return &n; }
bool operator== (CustomAddressOfClass const& that) const { return n == that.n; }
Expand Down
Loading

4 comments on commit 01e80d2

@pdimov
Copy link
Member

@pdimov pdimov commented on 01e80d2 Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMakeLists.txt still links to Boost::detail, which causes CI failures downstream (because now depinst.py doesn't install Detail as it's not a dependency.)

@akrzemi1
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reporting this. Should now be fixed by b5e9f06

@pdimov
Copy link
Member

@pdimov pdimov commented on 01e80d2 Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See also #123 which fixes more than that. :-)

@akrzemi1
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Merged.

Please sign in to comment.