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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:20:50+00:00 2026-05-12T16:20:50+00:00

The boost library, and it seems the upcoming C++0x standard, define various type trait

  • 0

The boost library, and it seems the upcoming C++0x standard, define various type trait templates to differentiate between objects which have trivial constructors, copy constructors, assignment, or destructors, versus objects which don’t. One of the most significant uses of this is to optimize algorithms for certain types, e.g. by using memcpy.

But, I don’t understand the real practical difference between all the various has_trivial_X templates. The C++ standard only defines two broad categories of types that concern us here: POD and non-POD. A type is non-POD if it has a defined constructor, copy constructor, assignment operator, or destructor. In other words, anything that’s not a built-in type, or a C-struct of built-in types, is not a POD.

So what’s the point of differentiating between, for example, has_trivial_assign and has_trivial_constructor? If an object has a non-trivial assignment operator OR a non-trivial constructor it’s not a POD. So under what circumstances would it be useful to know that an object has a trivial assignment operator, but a non-trivial constructor?

In other words, why not define a single type-trait template, is_pod<T>, and be done with it?

  • 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-12T16:20:50+00:00Added an answer on May 12, 2026 at 4:20 pm

    The POD type definition got relaxed in C++0A.

    A type may have a non-trivial-constructor, but may have a trivial assignment operator.

    E.g.

    struct X
    {
        X() : y( -1 ) {}
        X( int k, int v ) : y( k * v ) {}
    
        int y;
    };
    

    X could be ‘memcopy’-ied, but not trivially constructed.

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

Sidebar

Related Questions

I have a Win32 application that uses boost::asio and openssl library but it seems
Does C++ standard library and/or Boost have anything similar to the filter function found
I am having some trouble using the pantheios logging library with boost::threads. It seems
I have built the Boost library from these instructions: http://stackoverflow.com/questions/3529163/install-boost-library-in-visual-c-2008 Directory of the unzipped
I have a remote server which handles various different commands, one of which is
I have a section of code that uses a Boost library that results in
Could someone let me know whether boost thread library leaks. It seems to me
I'm wondering how good is the Boost Spirit Library. I have begun to read
I have some socket connection code that makes use of boost::asio which reads from
I have two machines in the same subnet. I want to exchange objects between

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.