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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:53:10+00:00 2026-05-23T13:53:10+00:00

I find that making a class non-copyable helps me a lot with my code

  • 0

I find that making a class non-copyable helps me a lot with my code quality. Initially I did this with boost::noncopyable, but I found the VC++ compiler errors to be not as helpful as with private members (double clicking lead to the wrong place in the code).

T(T const&);
T& operator=(T const&);

Indeed, it has alerted me to quite a few cases were classes were not passed as reference where they should have. So much so, that I would very much like to get a warning even on classes that I just need to copy construct once.

Is there a good way to do this? I was thinking for example of leaving above two methods private and adding a public T(T const&,bool dummy) constructor to call when I really want to copy construct. Or maybe alternatively make above two methods public and somehow activate a compiler warning when copy constructing, suppressing the warning where I do want to.

Or maybe there is an all together better way?

  • 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-05-23T13:53:11+00:00Added an answer on May 23, 2026 at 1:53 pm

    Not sure if it’s exactly what you want, but if you mark the copy constructor explicit then the class can’t be passed by value or copy-initialized, but you can copy-construct using direct initialization.

    You’d presumably want to keep the assignment operator private, maybe a NonAssignable base would be useful for that.

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

Sidebar

Related Questions

I find that in my daily Flex/Flash work, I do this number a lot:
Today I happens to find that one C# class can inherit one interface both
I find that getting Unicode support in my cross-platform apps a real pain in
I find that the .NET event model is such that I'll often be raising
I find that quite often Visual Studio memory usage will average ~150-300 MB of
I find that most books concerning C++ templates don't tell anything about whether it's
I find that I frequently end up writing a function that I always call
I was expecting to find that section within System.Web.Configuration namespace just like other Web.config
I was surprised recently to find that it's possible to have a return statement
I can't seem to find that option. Surely it's in there?

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.