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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:25:54+00:00 2026-05-24T03:25:54+00:00

So I was looking through some boost source code and came across this: (from

  • 0

So I was looking through some boost source code and came across this:

(from <boost/checked_delete.hpp>)

template<class T> inline void checked_delete(T * x)
{
    // intentionally complex - simplification causes regressions
    typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
    (void) sizeof(type_must_be_complete);
    delete x;
}

Anyone happen to know why it is implemented in this way? Wouldn’t sizeof(T) (for example) already be enough?

  • 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-24T03:25:56+00:00Added an answer on May 24, 2026 at 3:25 am

    Someone asked the same question earlier. This post written by Peter Dimov (one of the writers of boost/checked_delete.hpp) pretty much speaks for itself:

    • What’s the result of applying sizeof to an incomplete type?

    A compile-time error, unless the compiler chooses to return 0 as a
    nonstandard extension.

    • Why is sizeof called twice?

    The second sizeof is a workaround for a Metrowerks CodeWarrior bug in
    which the first typeof is never instantiated unless used.

    • Why is the result of sizeof cast to void? What exactly does that
      line
      do?

    Silences a compiler warning.

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

Sidebar

Related Questions

When looking through some code I took over, I came across this line: my
Looking through some old company code, I came across a for loop that looks
I was looking at some code that uses Boost.Function and have a question about
I'm looking through some old code and realize there are a ton of helper
Im looking through some code (unfortunatly the author isnt around anymore) and im wondering
I'm studying object literals and self-executing functions in Javascript. Looking through some YUI code
Looking through some apache logs, I've run into the following pattern several times (URL
I was looking through some apps in android like the gdocs, catch apps for
So I was looking through the asio tutorials and I compiled the synchronious daytime
I'm using Boost Graph to try and make sense of some dependency graphs I

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.