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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:21:24+00:00 2026-05-23T21:21:24+00:00

The explicit keyword is recommended for all most constructors which can be called with

  • 0

The explicit keyword is recommended for all most constructors which can be called with one argument, except for copy constructors.

For copy constructors, it has an use (to forbid implicit copying via function call, return, etc), but it’s not what’s usually wanted.

What about move constructors? Is there any reasonable use case to make them explicit? What’s the good practice here?

  • 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-23T21:21:26+00:00Added an answer on May 23, 2026 at 9:21 pm

    An explicit move constructors can affect compatibility with e.g. Standard algorithms. For instance, std::swap<T> requires that T be MoveConstructible. In turn, MoveConstructible is specified in terms of an expression, namely T u = rv; (where rv is an rvalue of type T).

    If there is neither a non-explicit copy constructor nor a non-explicit move constructor for a given type then T u = rv; is invalid and that type can’t be used with std::swap. (In this particular instance however it is possible to specialize std::swap to provide the desired functionality, e.g. by using T u(rv);).

    Put more simply, an explicit move or copy constructor defies expectations and can’t be used as well with generic code.

    Some other parts of the Standard library that put a MoveConstructible requirement:

    • the deleter of unique_ptr<T, D>
    • call wrappers, used in e.g. bind (all the decayed types that are passed are concerned)
    • thread, async, call_once (all specified in terms of call wrappers)
    • sort, stable_sort, nth_element, sort_heap
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know you can use C++ keyword 'explicit' for constructors of classes to prevent
I understand that the keyword explicit can be used to prevent implicit conversion. For
I understand the use of the explicit keyword to avoid the implicit type conversions
When it comes to constructors, adding the keyword explicit prevents an enthusiastic compiler from
What does the explicit keyword mean in C++?
I'm dreaming of a Python method with explicit keyword args: def func(a=None, b=None, c=None):
SSL can either be explicit or implicit as explained by this link: http://help.globalscape.com/help/secureserver2/Explicit_versus_implicit_SS.htm System.Net.Mail
Possible Duplicate: What does the explicit keyword in C++ mean? explicit CImg(const char *const
Possible Duplicates: What’s the point of the var keyword? Use of var keyword in
C++0x has added explicit conversion operators, but they must always be defined as members

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.