Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optional is "is_copy_constructible" when T is not. #54

Open
biocomp opened this issue May 10, 2018 · 2 comments
Open

optional is "is_copy_constructible" when T is not. #54

biocomp opened this issue May 10, 2018 · 2 comments

Comments

@biocomp
Copy link

biocomp commented May 10, 2018

Hi.
I encountered issues while trying to use std::vector<boost::optional<std::tuple<NonCopyable, std::function<...>>>. THis failed to compile on msvc.

Looks like it boiled down to this repro: https://godbolt.org/g/cFNcUN

#include <boost/optional.hpp>
#include <type_traits>
#include <optional>

struct NonCopyAble
{
    NonCopyAble() = default;

    NonCopyAble(const NonCopyAble&) = delete;
    NonCopyAble& operator=(const NonCopyAble&) = delete;

    NonCopyAble(NonCopyAble&&) = default;
    NonCopyAble& operator=(NonCopyAble&&) = default;
};

static_assert(!std::is_copy_constructible<NonCopyAble>::value, "NonCopyAble is_copy_constructible when shouldn't be");
static_assert(!std::is_copy_constructible<std::optional<NonCopyAble>>::value, "std::optional<NonCopyAble> is_copy_constructible when shouldn't be");    
static_assert(!std::is_copy_constructible<boost::optional<NonCopyAble>>::value, "boost::optional<NonCopyAble> is_copy_constructible when shouldn't be");    // This assert fails
@akrzemi1
Copy link
Member

Thanks for the report. I will investigate. I acknowledge the divergence between std::optional and boost::optional. But in general the expectation on transitive detectable copiability is not valid:

static_assert(!std::is_copy_constructible<std::vector<NonCopyAble>>::value,
              "vector of this is not copyable");

@joergbrech
Copy link

I encountered the same issue with std::is_copy_assignable, see here: https://stackoverflow.com/q/78157267/12173376

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants