// Copyright (c) 2020-2021 Antony Polukhin // // 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) #include #include #include #include // This class mimics libc++ implementation of std::chrono::duration with unfxed LWG3050 template class bogus_duration { public: bogus_duration() = default; template explicit bogus_duration(const T& val, typename std::enable_if< std::is_convertible::value // <= libstdc++ fix for LWG3050 is 's/T/const T&/g' >::type* = nullptr) : rep_(val) {} template bogus_duration(const bogus_duration& val, typename std::enable_if::value>::type* = nullptr) : rep_(val) {} Rep get_rep() const { return rep_; } private: Rep rep_{0}; }; struct struct_with_bogus_duration { std::optional> d0; std::optional> d1; }; struct struct_with_optional { std::optional a; std::optional b; std::optional c; std::optional d; std::optional e; std::optional f; }; int main() { struct_with_optional val{ std::chrono::seconds{1}, std::chrono::seconds{2}, std::chrono::seconds{3}, std::chrono::seconds{4}, std::chrono::seconds{5}, std::chrono::seconds{6}, }; using boost::pfr::get; BOOST_TEST(get<0>(val) == std::chrono::seconds{1}); BOOST_TEST(get<1>(val) == std::chrono::seconds{2}); BOOST_TEST(get<2>(val) == std::chrono::seconds{3}); BOOST_TEST(get<3>(val) == std::chrono::seconds{4}); BOOST_TEST(get<3>(val) > std::chrono::seconds{0}); BOOST_TEST(get<3>(val) > std::chrono::seconds{0}); struct_with_bogus_duration val2{bogus_duration{1}, bogus_duration{2}}; BOOST_TEST(get<0>(val2)->get_rep() == 1); BOOST_TEST(get<1>(val2)->get_rep() == 2); return boost::report_errors(); }