metaprogramming


Remove a const qualifier from a variable in D


I want to create a non-const copy of a variable. I am doing this inside a templated function, which has an in ref input, so the type (T) has the const set. I see a ConstOf function in https://dlang.org/phobos/std_traits.html but I cannot find an inverse so I can get a non-const type from T.
You might be interested in
std.traits.Unqual.
Note that this gives the type with all qualifiers removed, not just const.
If you want to remove all type qualifiers from a variable you can simply do cast() variable which will result in just the base type without any const/immutable/etc.
However beware that this will result in undefined behaviour and should be avoided!
See also: https://dlang.org/spec/const3.html#removing_with_cast

Related Links

Remove a const qualifier from a variable in D
Meta-modeling crud FROM/JOIN/WHERE statement fragments for higher-level analysis
Elixir: eval'ing code in module context using Code.eval_quoted/3
What is Declarative Meta-Programming?
Reconsolidate protocols in Elixir 1.2 or higher
Inserting an AST into a quote do end block without unquoting it
Transform quoted elixir code to a code string
Pattern matching benchmarking : Compiletime lookup vs Runtime lookup in D
Meta construction capabilities?
How to manipulate the value of variables based on an array of symbols in Julia?
Multiple #:build macros
Julia automatically generate functions and export them
Dealing with end keyword in macros for array indices
Implementation of AnyMap and runtime overhead of `struct Port(u32);`
Can function application be overriden with Macro in Elixir?
“Registering” trait implementations + factory method for trait objects

Categories

HOME
shell
fabricjs
ggplot2
ecmascript-6
hessian
rendering
telegram-bot
ado.net
vsm
tvos
python-multithreading
barcode
computer-science
32bit-64bit
categorical-data
enthought
activecollab
filechannel
modbus-tcp
fileserver
google-picker
sencha-touch
database-connection
visual-glitch
articulate-storyline
undertow
angular-routing
roslyn
game-theory
interbase
flooding
fragment-backstack
delimiter
firebase-analytics
genexus-sd
jaws
aws-codecommit
postback
dst
mockjax
turfjs
quickfixj
pop3
raft
openerp-7
spring-mvc-test
vmware-fusion
android-ibeacon
claims
http-request
snapchat
jide
ovf
libgphoto2
spring-integration-sftp
qtranslate
azure-cli
sundials
janus
template-toolkit
google-photos
gameplay-kit
baidu
pocketsphinx-android
cronexpression
reporting-services-2012
webjars
i386
ng-grid
android-dateutils
bizagi
jaunt-api
relativelayout
iokit
phonertc
zen-cart
page.js
text-search
graphics2d
pyobjc
nodelist
nsmenu
malformedurlexception
tinyxml
gnumeric
menubar
jammer
scrypt
abstract-data-type
dolby-audio-api
font-awesome-4.0.0
fb.ui
fragmenttransaction
iboutlet
fusefabric
xcelsius
clrstoredprocedure
nhprof
rowlex
scrollbars
burndowncharts
spread
lxr
data-mapping
mathematical-notation

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App