File tree Expand file tree Collapse file tree 2 files changed +66
-5
lines changed Expand file tree Collapse file tree 2 files changed +66
-5
lines changed Original file line number Diff line number Diff line change @@ -719,11 +719,7 @@ def _parse_template_specialization(self) -> TemplateSpecialization:
719719 args .append (TemplateArgument (dtype , param_pack ))
720720 else :
721721 # special case for sizeof...(thing)
722- if (
723- param_pack
724- and len (val .tokens ) == 1
725- and val .tokens [0 ].value == "sizeof"
726- ):
722+ if param_pack and val .tokens [- 1 ].value == "sizeof" :
727723 val .tokens .append (Token ("..." , "ELLIPSIS" ))
728724 tok = self ._next_token_must_be ("(" )
729725 raw_toks = self ._consume_balanced_tokens (tok )
Original file line number Diff line number Diff line change @@ -2352,3 +2352,68 @@ def test_sizeof_pack() -> None:
23522352 ]
23532353 )
23542354 )
2355+
2356+
2357+ def test_deduction_sizeof_pack () -> None :
2358+ content = """
2359+ template <typename ModuleTranslation, typename... ModuleTranslations>
2360+ SwerveDriveKinematics(ModuleTranslation, ModuleTranslations...)
2361+ -> SwerveDriveKinematics<1 + sizeof...(ModuleTranslations)>;
2362+ """
2363+ data = parse_string (content , cleandoc = True )
2364+
2365+ assert data == ParsedData (
2366+ namespace = NamespaceScope (
2367+ deduction_guides = [
2368+ DeductionGuide (
2369+ result_type = Type (
2370+ typename = PQName (
2371+ segments = [
2372+ NameSpecifier (
2373+ name = "SwerveDriveKinematics" ,
2374+ specialization = TemplateSpecialization (
2375+ args = [
2376+ TemplateArgument (
2377+ arg = Value (
2378+ tokens = [
2379+ Token (value = "1" ),
2380+ Token (value = "+" ),
2381+ Token (value = "sizeof" ),
2382+ Token (value = "..." ),
2383+ Token (value = "(" ),
2384+ Token (
2385+ value = "ModuleTranslations"
2386+ ),
2387+ Token (value = ")" ),
2388+ ]
2389+ ),
2390+ param_pack = True ,
2391+ )
2392+ ]
2393+ ),
2394+ )
2395+ ]
2396+ )
2397+ ),
2398+ name = PQName (segments = [NameSpecifier (name = "SwerveDriveKinematics" )]),
2399+ parameters = [
2400+ Parameter (
2401+ type = Type (
2402+ typename = PQName (
2403+ segments = [NameSpecifier (name = "ModuleTranslation" )]
2404+ )
2405+ )
2406+ ),
2407+ Parameter (
2408+ type = Type (
2409+ typename = PQName (
2410+ segments = [NameSpecifier (name = "ModuleTranslations" )]
2411+ )
2412+ ),
2413+ param_pack = True ,
2414+ ),
2415+ ],
2416+ )
2417+ ]
2418+ )
2419+ )
You can’t perform that action at this time.
0 commit comments