Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

[BUG] Can't pass dependent type template argument #727

Open

Description

Title: Can't pass dependent type template argument.

Minimal reproducer (https://cpp2.godbolt.org/z/W1dKeeKso):

f: <T> () std::vector<T::value_type>();
main: () = { }
Commands:
cppfront main.cpp2
clang++18 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -I . main.cpp

Expected result: std::vector<typename T::value_type>.

Actual result and error: std::vector<T::value_type>.

Cpp2 lowered to Cpp1:
//=== Cpp2 type declarations ====================================================


#include "cpp2util.h"



//=== Cpp2 type definitions and function declarations ===========================

template<typename T> [[nodiscard]] auto f() -> auto;
auto main() -> int;


//=== Cpp2 function definitions =================================================

template<typename T> [[nodiscard]] auto f() -> auto { return std::vector<T::value_type>();  }
auto main() -> int{}
Output:
build/main.cpp:18:74: error: template argument for template type parameter must be a type; did you forget 'typename'?
   18 | template<typename T> [[nodiscard]] auto f() -> auto { return std::vector<T::value_type>();  }
      |                                                                          ^
      |                                                                          typename 
/opt/compiler-explorer/clang-trunk-20231004/bin/../include/c++/v1/__iterator/wrap_iter.h:102:21: note: template parameter is declared here
  102 |     template <class _Tp, class _Alloc> friend class _LIBCPP_TEMPLATE_VIS vector;
      |                     ^
1 error generated.

See also:

Activity

  1. ghost added
    bug
    on Oct 4, 2023
  2. MaxSagebaum commented on May 16, 2024

    @MaxSagebaum
    Contributor

    It also seems that it is not possible to declare it in any working way current:
    typename does not work: (https://cpp2.godbolt.org/z/x4oYsj1E5)

    f: <T> () std::vector<typename T::value_type>();
    main: () = { }
    

    neither type:

    f: <T> () std::vector<type T::value_type>();
    main: () = { }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions