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

February 2026

S M T W T F S
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Mar. 2nd, 2026 03:32 am
Powered by Dreamwidth Studios