Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8189595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:19:54+00:00 2026-06-07T03:19:54+00:00

With const , as indicated by the comment, msvc 11 and g++ 4.7.0 refuse

  • 0

With const, as indicated by the comment, msvc 11 and g++ 4.7.0 refuse to compile this:

#include <memory>       // std::unique_ptr
#include <utility>      // std::move
using namespace std;

struct CommandLineArgs
{
    typedef unique_ptr<
        wchar_t const* const [],
        void(*)( wchar_t const* const* )
        > PointerArray;

    //PointerArray const  args;         // Oops
    PointerArray        args;
    int const           count;

    static wchar_t const* const* parsed(
        wchar_t const       commandLine[],
        int&                count
        )
    {
        return 0;
    }

    static void deallocate( wchar_t const* const* const p )
    {
    }

    CommandLineArgs(
        wchar_t const   commandLine[]   = L"",
        int             _               = 0
        )
        : args( parsed( commandLine, _ ), &deallocate )
        , count( _ )
    {}

    CommandLineArgs( CommandLineArgs&& other )
        : args( move( other.args ) )
        , count( move( other.count ) )
    {}
};

int main()
{}

The error messages do not seem to be particularly informative, but here’s g++’s output:

main.cpp: In constructor 'CommandLineArgs::CommandLineArgs(CommandLineArgs&&)':
main.cpp:38:38: error: use of deleted function 'std::unique_ptr::unique_ptr(const std::unique_ptr&) [w
ith _Tp = const wchar_t* const; _Dp = void (*)(const wchar_t* const*); std::unique_ptr = std::unique_ptr]'
In file included from c:\program files (x86)\mingw\bin\../lib/gcc/mingw32/4.7.0/include/c++/memory:86:0,
                 from main.cpp:1:
c:\program files (x86)\mingw\bin\../lib/gcc/mingw32/4.7.0/include/c++/bits/unique_ptr.h:402:7: error: declared here

Why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:19:55+00:00Added an answer on June 7, 2026 at 3:19 am

    You can not move const object. The error is because of your move constructor.

    The unique_ptr, has deleted copy constructor and move constructor declared as :

    unique_ptr( const unique_ptr & other );
    unique_ptr( unique_ptr && other );
    

    Since your unique_ptr is declated const, it picks copy constructor, not move constructor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code: const string LabelToFind = goTo considered Harmful; using (var file = new
I have a const int that is computed at compile time in my Managed
While striving for const-correctness, I often find myself writing code such as this class
I'm having trouble with templates and dependent types: namespace Utils { void PrintLine(const string&
I want to write a file_handle class like this #include <stdio.h> #include <iostream> #include
Pay attention to base64_decode in http://www.adp-gmbh.ch/cpp/common/base64.html std::string base64_decode(std::string const& encoded_string) The function is suppose
I'm making simple webcam program using OpenCV 2.3 and got stuck by the compile
SingleList.h #include ListBase.h #include DataNode.h #include SingleListIterator.h namespace list { class SingleListIterator; class SingleList
I've been using this site for a while and so far never needed to
I've been looking at C++0x threads and have this code: #include <vector> #include <iostream>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.