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 8477081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:21:21+00:00 2026-06-10T18:21:21+00:00

Summary: Why is the ‘=’ assignment operator inaccessible with two objects of the same

  • 0

Summary: Why is the ‘=’ assignment operator inaccessible with two objects of the same type std::unique_ptr<Expression, std::default_delete<Expression>>?
Mind you, in the code the types are written std::unique_ptr<Expression> but expand to the former in the IntelliSense error.

Info

IDE – Running Visual C++ 2010
OS – Windows Vista
Target – Console Application attempting to use what’s implemented of C++11

Some Background

I’ve been provided an example of an expression evaluator in C++ which apparently is up to the new standard alright, because what should be solid code is giving me errors and I’m guessing it’s because VC++ has no support for the feature. The first error I got was with the ‘make_unique’ method, VC++ said “identifier doesn’t exist”, so I implemented it myself

template<typename T>
std::unique_ptr<T> make_unique()
{
    return std::unique_ptr<T>(new T());
} // Basically just wrapping 'new'? Not sure why

Found a better one online but it gave errors, this ^ gives no errors. All I did was remove the …Args template parameter. I have a set of Expression classes that looks like this:

class Expression {
    virtual ~Expression() {}
};

class BinaryExpression : public Expression {
public:
     std::unique_ptr<Expression> lhs;
     std::unique_ptr<Expression> rhs;
     virtual char GetType() const = 0; // +,-,/,*
};
// Then MulExpression, DivExpression, PlusExpression, blah blah

Now here’s where I get the error, mind you, ParseAdditiveExpression()’s return type is

// expr, lhs, and rhs are all of the same type
std::unique_ptr<Expression>:
auto rhs = ParseAdditiveExpression();
auto expr = make_unique<MulExpression>(); // Tried using: std::unique_ptr<Expression> expr;
expr->lhs = lhs; // Trouble Makers
expr->rhs = rhs; // All produce
lhs = expr; // The same errors

The error is as follows:

1   IntelliSense: "std::unique_ptr<_Ty, _Dx> &std::unique_ptr<_Ty, _Dx>::operator=(const std::unique_ptr<_Ty, _Dx> &) [with _Ty=Expression, _Dx=std::default_delete<Expression>]" 
(declared at line 2352 of "C:\Program Files\Microsoft Visual Studio 10.0\VC\include\memory")
is inaccessible 
c:\users\s_miller47\documents\visual studio 2010\projects\_vc++\powercalc\mathparser.h  133

Now, I think this may have something to do with the ‘const’ at the right size of the ‘=’, but I’ve tried changing the functions return type to fit, with * or & after the return type, tried de-referencing (‘*’) the value before I set it to expr->lhs, even tried (‘&’)

So if the operator is inaccessible how do I fix it? Do I have to define the operator myself? (nonsense) Well, here is the full code: PasteBin Source Code Link

  • 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-10T18:21:23+00:00Added an answer on June 10, 2026 at 6:21 pm

    std::unique_ptr is non-assignable and non-copyable. If you want to make such assignment, you will need to use std::move():

    lhs = std::move(expr);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Summary: I want to save two classes of the same name and different namespaces
Summary For some reason, git commands don't work the same when I am logged
Summary: I'm trying to write a text string to a column of type varchar(max)
Summary: Have you ever made an interface between two -- or better yet even
Summary of the question: How do i scaffold two or more tables with linq
Summary I have seen a few questions on std::vector recently, and out of curiosity
Summary: I want a horizontal row of ImageButtons to scale down evenly to fit
Summary: I want to display a value (in a text box) stored in another
Summary: I have passed the name of the id select tag into an Array.
Summary : is there a way to get the unique lines from a file

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.