Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for variadic templates #35

Open
davidbeckingsale opened this issue Aug 29, 2018 · 4 comments
Open

Support for variadic templates #35

davidbeckingsale opened this issue Aug 29, 2018 · 4 comments

Comments

@davidbeckingsale
Copy link
Member

It seems like variadic templates don't work, it would be good if the following could be used:

        - decl: |
            template <typename strategy, typename... Args>
            Allocator makeAllocator(const std::string& name, Args... args)
          cxx-template:
            - instantiation: <umpire::strategy::DynamicPool, int, int>

Obviously I would expect to have to list all the arguments, but it would be nice if it worked 😄

@ltaylor16
Copy link
Member

It looks like that should work if you list the specific types in the instantiation field.

varargs for function would be more of a problem I think. Fortran supports an OPTIONAL attribute that could be used to support some uses of vararg. But supporting something like printf is not really possible. Are you using function varargs anywhere?

@davidbeckingsale
Copy link
Member Author

Nope, just using variadic templates. Let me give this another try - I thought I was hitting an error, but maybe I am mis-remembering.

@davidbeckingsale
Copy link
Member Author

It gives me an error:

[100%] Running shroud umpire_shroud.yaml
Traceback (most recent call last):
  File "/Users/beckingsale1/Library/Python/2.7/bin/shroud", line 9, in <module>
    load_entry_point('shroud==0.10.1', 'console_scripts', 'shroud')()
  File "build/bdist.macosx-10.13-intel/egg/shroud/main.py", line 249, in main
  File "build/bdist.macosx-10.13-intel/egg/shroud/main.py", line 398, in main_with_args
  File "build/bdist.macosx-10.13-intel/egg/shroud/ast.py", line 1536, in create_library_from_dictionary

  File "build/bdist.macosx-10.13-intel/egg/shroud/ast.py", line 1481, in add_declarations

  File "build/bdist.macosx-10.13-intel/egg/shroud/ast.py", line 1481, in add_declarations

  File "build/bdist.macosx-10.13-intel/egg/shroud/ast.py", line 1480, in add_declarations

  File "build/bdist.macosx-10.13-intel/egg/shroud/ast.py", line 124, in add_declaration

  File "build/bdist.macosx-10.13-intel/egg/shroud/declast.py", line 1533, in check_decl
  File "build/bdist.macosx-10.13-intel/egg/shroud/declast.py", line 522, in decl_statement
  File "build/bdist.macosx-10.13-intel/egg/shroud/declast.py", line 704, in template_statement
  File "build/bdist.macosx-10.13-intel/egg/shroud/declast.py", line 180, in mustbe
  File "build/bdist.macosx-10.13-intel/egg/shroud/declast.py", line 185, in error_msg
RuntimeError: Parse Error
template<typename strategy, typename... Args>
Allocator makeAllocator(const std::string& name, Args... args)

                                    ^
Expected ID, found VARARG

@davidbeckingsale
Copy link
Member Author

I'm running in to another error here - I can't instantiate a template with a type that isn't a primitive data-type:

       - decl: |
            template <typename strategy>
            Allocator makeAllocator(const std::string& name)
          cxx-template:
            - instantiation: <umpire::strategy::DynamicPool>

fails with:

Traceback (most recent call last):
  File "/Users/beckingsale1/Library/Python/2.7/bin/shroud", line 9, in <module>
    load_entry_point('shroud==0.10.1', 'console_scripts', 'shroud')()
  File "build/bdist.macosx-10.13-intel/egg/shroud/main.py", line 249, in main
  File "build/bdist.macosx-10.13-intel/egg/shroud/main.py", line 398, in main_with_args
  File "build/bdist.macosx-10.13-intel/egg/shroud/ast.py", line 1536, in create_library_from_dictionary

  File "build/bdist.macosx-10.13-intel/egg/shroud/ast.py", line 1481, in add_declarations

  File "build/bdist.macosx-10.13-intel/egg/shroud/ast.py", line 1481, in add_declarations

  File "build/bdist.macosx-10.13-intel/egg/shroud/ast.py", line 1480, in add_declarations

  File "build/bdist.macosx-10.13-intel/egg/shroud/ast.py", line 141, in add_declaration
    node.col_offset = col_offset
  File "build/bdist.macosx-10.13-intel/egg/shroud/ast.py", line 201, in add_function

  File "build/bdist.macosx-10.13-intel/egg/shroud/ast.py", line 1090, in __init__

  File "build/bdist.macosx-10.13-intel/egg/shroud/ast.py", line 1380, in parse_instantiation

  File "build/bdist.macosx-10.13-intel/egg/shroud/declast.py", line 740, in template_argument_list
  File "build/bdist.macosx-10.13-intel/egg/shroud/declast.py", line 439, in declaration_specifier
AttributeError: 'FunctionNode' object has no attribute 'unqualified_lookup'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants