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

  • Home
  • SEARCH
  • 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 8729279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:48:21+00:00 2026-06-13T08:48:21+00:00

I have the following data container: struct Node { explicit Node(const std::vector<Data>& _data, const

  • 0

I have the following data container:

struct Node
{
    explicit Node(const std::vector<Data>& _data, const Value& _value): data(_data), value(_value)
    {
    }

    const std::vector<Data> data;
    const Value value;
};

I wish to write a mock along these lines:

class MockVisitor: public IVisitor
{
public:
    virtual void operator()(const Node& _node)
    {
        node = _node;
    }

    Node node;
};

However, I’m getting the error:

error C2582: 'operator =' function is unavailable in 'Node'. 

I’m presuming this is because I can only assign to a const Node. Is there anyway for my to cast away this error? Remember this is only a mock class. I’m simply trying to record the value passed into operator()() so I can check it in my unit test.

  • 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-13T08:48:22+00:00Added an answer on June 13, 2026 at 8:48 am

    Since the member variables data and value are declared as constant, the operator= is deleted. This is the reason you can not use it, hence the compilation error.

    This should work :

    class MockVisitor: public IVisitor
    {
    public:
        virtual void operator()(const Node& _node)
        {
            node.reset( new Node( _node ) );
        }
    
        std::unique_ptr< Node > node;
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have the following two data structures: std::vector<int> all_items; std::set<int> bad_items; The all_items
I have a std::vector<Word> data that is off of the struct below: struct Word
I'm programming for a µC, i have following data Structure: typedef struct { RF12Head
I have the following data structure in C: typedef struct { void* buffer; ...
I have a function f , defined as following: struct s { void *data;
I have the following markup: <div class=event-row-container> <div data-id=1 class=ios-location-name>Location Name</div> <div data-id=1 class=ios-location-detail
I have the following casting problem when my data structure sSpecificData contains a field
I have a txt file which contains data in the following format: X1 Y1
I have multiple data entries that contain the following information: id_number name1 date name2
I have a component called a TableDataViewer that contains the following pieces of data

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.