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

Since I have started using this site, I keep hearing about the Boost library.
i have little problem with boost::asio library. My app receive and process data asynchronously,
I have a section of code that uses a Boost library that results in
When the Boost library/headers is used with VC++ 9 compilers (Visual C++ 2008 Express
What is the latest version of the Boost library that is compatible with Microsoft
Is it possible to create a multithreading application in VC6 with boost library? If
Several times, while perusing the Boost library's documentation, I've run across return values that
In the Boost Signals library, they are overloading the () operator. Is this a
Can Spirit (part of Boost C++ library) be used to parse out binary data
I am working on a client-server application that uses boost::serialization library for it's serialization

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.