digitalmars.D - When do you use templates instead of CTFE?
- Dan (3/3) Mar 23 2012 Since there is CTFE, I keep running into, do I really need this
- Timon Gehr (6/8) Mar 24 2012 You use templates in combination with CTFE if
- Nick Sabalausky (4/14) Mar 25 2012 Yea, the general rule of thumb is "If you can do it with CTFE, then do s...
- Jonathan M Davis (4/22) Mar 25 2012 Generally, you end up having to use templates for stuff that operates on...
- James Miller (4/10) Mar 25 2012 Often I end up using the same function in CTFE and runtime.
- Jonathan M Davis (3/4) Mar 25 2012 That's pretty much the idea behind CTFE in the first place.
Since there is CTFE, I keep running into, do I really need this as a template parameter? Why not put this in a constructor. And so on...
Mar 23 2012
On 03/24/2012 07:42 AM, Dan wrote:Since there is CTFE, I keep running into, do I really need this as a template parameter? Why not put this in a constructor. And so on...You use templates in combination with CTFE if - You have to perform computations on types. - You want template instantiation syntax. (If this is the only reason, the template will just wrap a CTFE computation)
Mar 24 2012
"Timon Gehr" <timon.gehr gmx.ch> wrote in message news:jkkbqv$2pvu$3 digitalmars.com...On 03/24/2012 07:42 AM, Dan wrote:Yea, the general rule of thumb is "If you can do it with CTFE, then do so, otherwise use templates."Since there is CTFE, I keep running into, do I really need this as a template parameter? Why not put this in a constructor. And so on...You use templates in combination with CTFE if - You have to perform computations on types. - You want template instantiation syntax. (If this is the only reason, the template will just wrap a CTFE computation)
Mar 25 2012
On Sunday, March 25, 2012 17:55:56 Nick Sabalausky wrote:"Timon Gehr" <timon.gehr gmx.ch> wrote in message news:jkkbqv$2pvu$3 digitalmars.com...Generally, you end up having to use templates for stuff that operates on types, whereas CTFE works for stuff that can be normal functions. - Jonathan M DavisOn 03/24/2012 07:42 AM, Dan wrote:Yea, the general rule of thumb is "If you can do it with CTFE, then do so, otherwise use templates."Since there is CTFE, I keep running into, do I really need this as a template parameter? Why not put this in a constructor. And so on...You use templates in combination with CTFE if - You have to perform computations on types. - You want template instantiation syntax. (If this is the only reason, the template will just wrap a CTFE computation)
Mar 25 2012
On 26 March 2012 12:35, Jonathan M Davis <jmdavisProg gmx.com> wrote:On Sunday, March 25, 2012 17:55:56 Nick Sabalausky wrote:Often I end up using the same function in CTFE and runtime. -- James MillerYea, the general rule of thumb is "If you can do it with CTFE, then do so, otherwise use templates."Generally, you end up having to use templates for stuff that operates on types, whereas CTFE works for stuff that can be normal functions. - Jonathan M Davis
Mar 25 2012
On Monday, March 26, 2012 12:39:36 James Miller wrote:Often I end up using the same function in CTFE and runtime.That's pretty much the idea behind CTFE in the first place. - Jonathan M Davis
Mar 25 2012