Compare commits

..

11 Commits

Author SHA1 Message Date
Andrzej Krzemienski 0fca17a0a8 GHA fix 3 2026-02-16 13:00:57 +01:00
Andrzej Krzemienski 3ce5e44ae2 GHA fix 2 2026-02-16 12:39:36 +01:00
Andrzej Krzemienski 64aa3f918c change GHA setup 2026-02-16 12:27:50 +01:00
Andrzej Krzemienski 003b1e5415 fix ranges triviality test on too old GCC 2026-02-10 19:12:41 +01:00
Andrzej Krzemienski d3f6501728 docs: operator bool fix 2026-02-10 01:54:32 +01:00
Andrzej Krzemienski 802715d295 add comparison for none and docs 2026-02-10 01:51:53 +01:00
Andrzej Krzemienski 437c1eb626 really fix the factory bug 2026-02-08 23:42:24 +01:00
Andrzej Krzemienski 6a2e169f23 fix conditional constexpr init in MSVC 2026-02-08 20:01:24 +01:00
Andrzej Krzemienski f0059887bc fix factory application syntax 2026-02-08 18:56:56 +01:00
Andrzej Krzemienski b8e5c07f2f fix constexpr tests 2026-02-08 12:15:52 +01:00
Andrzej Krzemienski f564e11dea add robust constexpr support 2026-02-08 11:27:30 +01:00
8 changed files with 39 additions and 79 deletions
+6 -1
View File
@@ -142,8 +142,9 @@ jobs:
- toolset: clang
compiler: clang++-16
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-24.04
os: ubuntu-latest
install: clang-16
container: ubuntu:24.04
- toolset: clang
compiler: clang++-17
cxxstd: "03,11,14,17,20,2b"
@@ -224,6 +225,10 @@ jobs:
cxxstd: 14,latest
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.1
cxxstd: "11,14,17,20,latest"
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.2
cxxstd: "14,17,20,latest"
addrmd: 32,64
+9 -8
View File
@@ -2,7 +2,6 @@
Boost.Optional
Copyright (c) 2003-2007 Fernando Luis Cacciola Carballal
Copyright (C) 2014 - 2026 Andrzej Krzemieński.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
@@ -26,22 +25,24 @@ __SPACE__
[: `constexpr optional<T>::optional() noexcept;`]
* [*Postconditions:] `*this` does ['not] contain a value (is "uninitialized").
* [*Remarks:] No contained value is initialized. For every object type `T` these constructors are core constant expressions.
* [*Effect:] Default-Constructs an `optional`.
* [*Postconditions:] `*this` is [_uninitialized].
* [*Notes:] T's default constructor [_is not] called.
* [*Example:]
``
optional<T> oN ;
assert ( !oN ) ;
optional<T> def ;
assert ( !def ) ;
``
__SPACE__
[#reference_optional_constructor_none_t]
[: `constexpr optional<T>::optional( none_t ) noexcept;`]
* [*Postconditions:] `*this` does ['not] contain a value (is "uninitialized").
* [*Remarks:] No contained value is initialized. For every object type `T` these constructors are core constant expressions. The expression
* [*Effect:] Constructs an `optional` uninitialized.
* [*Postconditions:] `*this` is [_uninitialized].
* [*Notes:] `T`'s default constructor [_is not] called. The expression
`boost::none` denotes an instance of `boost::none_t` that can be used as
the parameter.
* [*Example:]
-11
View File
@@ -47,17 +47,6 @@
`std::ranges::find(rng, boost::none)`] [`std::vector<optional<int>> rng;`
`std::ranges::find(rng, boost::optional<int>{})`] [optional<T> is never [@https://en.cppreference.com/w/cpp/concepts/equality_comparable `std::equality_comparable_with`] `nullopt_t` in `std`. ] ]
[ [```
void test(vector<optional<T>> rng, T val) {
std::ranges::find(rng, val);
}
```] [```
void test(vector<optional<T>> rng, T val) {
std::ranges::find(rng, make_optional(val));
}
```] [The same code for `std::optional` compiles but is ['undefined behavior] when `T` is itself an `optional`. ] ]
]
+1 -1
View File
@@ -18,7 +18,7 @@
`constexpr` support:
* In C++11, some constructors and `const`-qualified accessors become usable
in compile-time contexts (are ['core constant expressions]) for types
in compile-time contexts (are ['core constant expressions] for types
satisfying certain constraints.
* In C++14 even some mutating operations become core constant expressions (those
that do not require changing the state of `optional` from not having a value to
@@ -122,15 +122,6 @@ struct constexpr_guarded_storage
BOOST_CXX14_CONSTEXPR void reset () noexcept { init_ = false; }
//~constexpr_guarded_storage() = default;
#if (defined(_MSC_VER) && 1910 <= _MSC_VER && _MSC_VER <= 1916)
// Workaround for MSVC 14.1x bug where it eagerly tries to define the copy/move operations
// these are declared but never defined
constexpr_guarded_storage(const constexpr_guarded_storage&);
constexpr_guarded_storage(constexpr_guarded_storage&&);
constexpr_guarded_storage& operator=(const constexpr_guarded_storage&);
constexpr_guarded_storage& operator=(constexpr_guarded_storage&&);
#endif
};
@@ -164,15 +155,6 @@ struct fallback_guarded_storage
}
~fallback_guarded_storage() { if (init_) storage_.value_.T::~T(); }
#if (defined(_MSC_VER) && 1910 <= _MSC_VER && _MSC_VER <= 1916)
// Workaround for MSVC 14.1x bug where it eagerly tries to define the copy/move operations
// These are declared but never defined
fallback_guarded_storage(const fallback_guarded_storage&);
fallback_guarded_storage(fallback_guarded_storage&&);
fallback_guarded_storage& operator=(const fallback_guarded_storage&);
fallback_guarded_storage& operator=(fallback_guarded_storage&&);
#endif
};
@@ -367,9 +349,7 @@ namespace boost {
}
template <typename U,
BOOST_OPTIONAL_REQUIRES(::std::is_constructible<T, U&&>),
BOOST_OPTIONAL_REQUIRES(!optional_detail::is_typed_in_place_factory<U>),
BOOST_OPTIONAL_REQUIRES(!optional_detail::is_in_place_factory<U>)>
BOOST_OPTIONAL_REQUIRES(::std::is_constructible<T, U&&>)>
constexpr explicit optional(U&& v)
: storage(optional_ns::in_place_init, optional_detail::forward_<U>(v))
{}
@@ -483,9 +463,7 @@ namespace boost {
BOOST_OPTIONAL_REQUIRES(!::std::is_same<typename ::std::decay<U>::type, optional>),
BOOST_OPTIONAL_REQUIRES(!optional_detail::conjunction<::std::is_scalar<T>, ::std::is_same<T, BOOST_OPTIONAL_DECAY(U)>>),
BOOST_OPTIONAL_REQUIRES(::std::is_constructible<T, U>),
BOOST_OPTIONAL_REQUIRES(::std::is_assignable<T&, U>),
BOOST_OPTIONAL_REQUIRES(!optional_detail::is_typed_in_place_factory<U>),
BOOST_OPTIONAL_REQUIRES(!optional_detail::is_in_place_factory<U>)
BOOST_OPTIONAL_REQUIRES(::std::is_assignable<T&, U>)
>
BOOST_OPTIONAL_CXX20_CONSTEXPR optional& operator=(U&& v)
{
+21
View File
@@ -10,6 +10,7 @@
// akrzemi1@gmail.com
#include "boost/optional.hpp"
#include <string>
#ifdef BOOST_OPTIONAL_USES_UNION_IMPLEMENTATION
@@ -129,4 +130,24 @@ namespace test_optional_ref
static_assert(*iref == 9, "");
}
namespace test_msvc_14_1
{
struct Aggr
{
boost::optional<std::string> os;
};
void test()
{
Aggr a;
Aggr b = a;
b = a;
Aggr c = Aggr();
b = Aggr();
(void)a;
(void)b;
(void)c;
}
}
#endif // BOOST_OPTIONAL_USES_UNION_IMPLEMENTATION
-33
View File
@@ -105,42 +105,9 @@ void test_assign()
#endif
}
// begin Boost.Log case
template <typename CharT>
struct basic_formatter
{
template< typename FunT >
basic_formatter(FunT&& fun) {}
template< typename FunT >
basic_formatter& operator= (FunT&& fun)
{
return *this;
}
};
template< typename CharT>
struct chained_formatter
{
};
void test_boost_log_case()
{
#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
boost::optional<basic_formatter<char>> of( boost::in_place(chained_formatter<char>()) );
of = boost::in_place(chained_formatter<char>());
#endif //BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
}
// end Boost.Log case
int main()
{
test_ctor();
test_assign();
test_boost_log_case();
return boost::report_errors();
}
@@ -32,7 +32,6 @@ void test()
//BOOST_TEST(v);
boost::optional<boost::optional<int>> vv;
bool xx = vv?true : false;
(void)xx;
BOOST_TEST_EQ(*v, 7);
#endif
}