templates - D: Creating an array of templated objects -


i'm trying create array of regex objects, so: regex[] regexes;. compilation fails main.d(46): error: template std.regex.regex(char) used type.

i find documentation cryptic. understand templates generate code on compilation, don't see what's preventing me creating array of regex.


there's existing question on stackoverflow same problem, deals c++, not d.

you cannot create regex object without first instantiating template type. because actual type generated @ compile time based on instantiation type give. regex not actual type, template function allowing generate type when instantiated.

in case want change:

regex[] regexes; 

into:

regex!char[] regexes; 

to tell compiler regex contains chars opposed derived type. means instantiating regex template type char.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

wso2esb - How to concatenate JSON array values in WSO2 ESB? -