www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3750] New: Template specialization based on shared doesn't seem to work

http://d.puremagic.com/issues/show_bug.cgi?id=3750

           Summary: Template specialization based on shared doesn't seem
                    to work
           Product: D
           Version: 2.040
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: jason.james.house gmail.com


--- Comment #0 from Jason House <jason.james.house gmail.com> 2010-01-28
20:00:51 PST ---
Example #1:
template foo( T U == shared ){ enum U foo = 1; }
static assert(is(foo!(shared int) == int));
------------------------------------------------
error.d(1): found '==' when expecting ')'
error.d(1): members of template declaration expected
error.d(1): Declaration expected, not ')'
error.d(1): unrecognized declaration


Example #2:
template foo( T ) if (is(T U == shared)){ enum U foo = 1; }
static assert(is(foo!(shared int) == int));
-------------------------------------------------
alt.d(2): Error: static assert  (is(foo!(shared(int)) == int)) is false


Example #3:
template foo( T ) if (is(T U == shared)){ enum U foo = 1; }
pgragma(msg, foo!(shared int));
--------------------------------------------------
alt.d(1): Error: identifier 'U' is not defined
alt.d(1): Error: U is used as a type
alt.d(1): Error: variable alt.foo!(shared(int)).foo voids have no value
alt.d(2): Error: template instance alt.foo!(shared(int)) error instantiating
1


It seems like is expressions work alright:
void main(){
    shared int x;
    static if (is(x y == shared))
    {
        static assert( is (y == int) );
        static assert( !is (y == shared) );
    }
}

... although this example (incomplete) fails:
        template isValidNumericType( T )
        {
          static if (is(T U == shared)){
            enum bool isValidNumericType = isIntegerType!( U ) ||
                                           isPointerType!( U );
          }
          else
          {
            enum bool isValidNumericType = isIntegerType!( T ) ||
                                           isPointerType!( T );
          }
        }
-----------------------------------------
tango/core/Atomic.d(828): Error: static assert
(isValidNumericType!(shared(int))) is false

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 28 2010