How do I add.a CDialogEx to a std::vector avoiding “attempting to reference a deleted function”?

C++ and Windows are fighting with each other, and I need to get them to stop.

I have a Visual Studio 2022 generated class that implements CDialogEx, and I need to add this to an array capable of insert. This is hard.

The class that Visual Studio 2022 generated for the dialog looks like this:

class SignPage : public CDialogEx
{
    DECLARE_DYNAMIC(SignPage)

public:
    SignPage(CWnd* pParent = nullptr);   // standard constructor
    virtual ~SignPage();

// Dialog Data
#ifdef AFX_DESIGN_TIME
    enum { IDD = IDD_SIGN_PAGE };
#endif

protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

    DECLARE_MESSAGE_MAP()
};

I understand that the array capable of insert is std::vector, however inserting any Windows generated objects into std::vector results in “attempting to reference a deleted function” errors as Windows has deleted the copy and move functions in their objects.

I do not want the array capable of insert to molest the Windows provided objects in any way, and so I understand std:unique_ptr is what I need so that I add a pointer to the Windows provided objects to the list.

I instantiate the object and vector like this, and the compiler likes it:

    std::vector<std::unique_ptr<SignPage>> m_dlgs;
    std::unique_ptr<SignPage> upm_dlg1 = std::make_unique<SignPage>();

Now I try and insert the upm_dlg1 into m_dlgs like this:

    std::vector<std::unique_ptr<SignPage>>::iterator it;
    it = m_dlgs.begin();
    m_dlgs.insert(it, upm_dlg1); <---- error happens here

The addition of the last line above causes a compile error inside the template rendering unique pointers as follows:

1>C:Program FilesMicrosoft Visual Studio2022CommunityVCToolsMSVC14.40.33807includexmemory(700,82): error C2280: 'std::unique_ptr<SignPage,std::default_delete<SignPage>>::unique_ptr(const std::unique_ptr<SignPage,std::default_delete<SignPage>> &)': attempting to reference a deleted function

Does anyone know what steps I must take to fix this?

My limitations are:

  • The objects I need to add to the array capable of insert are generated by Visual Studio for the benefit of Windows. My options to modify these objects are limited.

  • The compiler error is being triggered deep inside what I understand to be the template implementing unique_ptr. I am assuming this is the joy of c++ compiler errors.

  • I am led to believe that std::vector is the collection I should be using, but this may not be the case, can anyone confirm? I have no need for sorting or any other complexity, just a simple array where I can insert and remove without in any way touching the object in the list.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật