www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1012] New: type templates don't support default arguments

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1012

           Summary: type templates don't support default arguments
           Product: D
           Version: 1.007
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P3
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: thomas-dloop kuehne.cn


# class Bar(T = int){
# }
# 
# void foo(T = int)(){
# }
# 
# void main(){
#    foo(); // success
#    auto b = new Bar(); // fails
# }

test.d(9): class test.Bar(T = int) is used as a type
test.d(9): Error: new can only create structs, dynamic arrays or class objects, 
not void's


-- 
Feb 28 2007
next sibling parent reply Don Clugston <dac nospam.com.au> writes:
d-bugmail puremagic.com wrote:
 http://d.puremagic.com/issues/show_bug.cgi?id=1012
 
            Summary: type templates don't support default arguments
            Product: D
            Version: 1.007
           Platform: PC
         OS/Version: All
             Status: NEW
           Severity: normal
           Priority: P3
          Component: DMD
         AssignedTo: bugzilla digitalmars.com
         ReportedBy: thomas-dloop kuehne.cn
 
 
 # class Bar(T = int){
 # }
 # 
 # void foo(T = int)(){
 # }
 # 
 # void main(){
 #    foo(); // success
 #    auto b = new Bar(); // fails
 # }
 
 test.d(9): class test.Bar(T = int) is used as a type
 test.d(9): Error: new can only create structs, dynamic arrays or class
objects, 
 not void's
 
 

I'd expect to have to write auto b = new Bar!()(); or at least auto b = new Bar!();
Mar 01 2007
parent Sean Kelly <sean f4.ca> writes:
Don Clugston wrote:
 Are you allowed to leave out the !() in class template instantations?

No, but I think you perhaps should be allowed. I posted as much here asking for comments, but the thread got no replies: http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=48672
Mar 01 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1012


Stewart Gordon <smjg iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement




--- Comment #3 from Stewart Gordon <smjg iname.com>  2009-06-29 02:04:23 PDT ---
AIUI this isn't supposed to work.  If we allowed such implicit template
instantiation everywhere, it would create ambiguities (alias declarations come
to mind).  That's why, at the moment, it's explicitly allowed in some contexts
where it's unambiguous, such as IFTI and (to some degree) mixins.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 29 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1012



--- Comment #4 from Rainer Schuetze <r.sagitario gmx.de> 2009-09-30 14:48:47
PDT ---
Created an attachment (id=466)
convert TypeIdentifer refering to TemplateDeclaration to TypeInstance

I don't expect any additional ambiguities, because the template types are in
the same namespace as all other identifers anyway (apart from version and debug
identifiers). 
This patch against 2.032 converts a TypeIdentifier (as created by the parser)
into a TypeInstance if name lookup revealed that it is actually a template.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 30 2009