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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:24:11+00:00 2026-06-15T11:24:11+00:00

Take the following bit of code that uses boost::asio. #include <boost/asio.hpp> using boost::asio::ip::tcp; class

  • 0

Take the following bit of code that uses boost::asio.

#include <boost/asio.hpp>

using boost::asio::ip::tcp;

class SocketTest
{

private:            

    boost::asio::io_service& mIOService;
    tcp::acceptor mAcceptor; // Comment this line

public:

    SocketTest(boost::asio::io_service& io_service)
        : mIOService(io_service)
        , mAcceptor(io_service, tcp::endpoint(tcp::v4(), 8080)) // Comment this line
    {      
    }
};

If you comment the two tagged lines the compiler (Visual Studio 2010) gives out the following warning when compiling on /W4.

warning C4512: 'SocketTest' : assignment operator could not be generated

What makes those two lines so special? Why does their existence allow the generation of the assignment operator?

  • 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-15T11:24:13+00:00Added an answer on June 15, 2026 at 11:24 am

    The reason for this behaviour is that tcp::acceptor is not copyable (it inherits from basic_io_object, whose copy assignment operator is private, so its own copy assignment operator is not implicitly declared). Having a non-copyable member avoids the generation of the implicitly declared copy assignment operator, but does not raise a warning because this is considered the expected behaviour.

    On the other hand, if you comment-out those two lines, your class is left with just a reference member; this also makes your class non-copyiable, but does raise a warning according to Visual Studio documentation. I agree that this is also expected, but the compiler implementers decided to give you a warning just in case. The reason may be that making a class explicitly non-copyable (such as is the case with basic_io_object) is an explicit design decision, but I am just guessing here.

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

Sidebar

Related Questions

Take the following property: public string Foo { get; private set; } Using reflection,
I've got the following bit of code on an intranet site that displays a
Why do I receive a black screen when using the following code to take
Take the following code: private var m_iQuanitity:int; public function get quantity():int { return m_iQuantity;
Take the following naive implementation of a nested async loop using the ThreadPool: ThreadPool.SetMaxThreads(10,
Take the following example, I have a class public class SomeItem { public string
Take the following : #include <stdio.h> main() { unsigned long long verybig = 285212672;
Take the following code snippet: SPAttachmentCollection attachments = item.Attachments ; What exactly is SPAttachmentCollection
Take the following code: <abbr title=World Health Organization>WHO</abbr> Can we style an abbr tag's
Take the following snippet: 1 #include <stdio.h> 2 #include <stdlib.h> 3 int foo(char [6]);

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.