billroper: (Default)
[personal profile] billroper
The next person who casts away constness on an object that I'm deliberately returning as a const object because I don't want them modifying it except through the specific functions that I've provided to do so is going to get thrashed about the head and shoulders.

Date: 2004-07-27 09:49 pm (UTC)
From: [identity profile] mrlogic.livejournal.com
Hey, here's your problem:

#include Deviousness.h
#include MessedUpValues.h

void ScrewUpBillsCode()
{
     const BillsObjectType* billsObject = BillsFunction();
     BillsObjectType* screwedObject = const_cast<BillsObjectType*>(billsObject);
     screwedObject->member = k_CRAP;

// mwahaha
}

Date: 2004-07-28 11:44 am (UTC)
From: [identity profile] phillip2637.livejournal.com
How about...don't return objects you want protected? Return identifiers instead and and act as a proxy for the functions that you decide are valid.

Ya, I know, not nearly as satisfying as the "thrashing" thing. :-)

Profile

billroper: (Default)
billroper

April 2026

S M T W T F S
    1 2 3 4
5 6 7 8 9 10 11
12131415161718
19202122232425
2627282930  

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Apr. 12th, 2026 08:49 pm
Powered by Dreamwidth Studios