[PATCH] D147722: [Concepts] Fix Function Template Concepts comparisons

Alexander Yermolovich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 7 11:11:52 PDT 2023


ayermolo added a comment.

OK was able to create small(ish) repro

main.h

  #include <type_traits>
  enum class Enums {
      ACCESS = 0,
      MAP = 1,
  };
  
  template <typename TDM,typename TM, Enums kStrategy = Enums::MAP>
  class DMap {
   public:
      template <typename TIDR>
          requires std::is_convertible_v<TIDR, TDM>
        void getOrCreate(TIDR v);
  };
  
  template <typename TDM, typename TM>
  class DMap<TDM, TM, Enums::ACCESS> {
   public:
      template <typename TIDR>
          requires std::is_convertible_v<TIDR, TDM>
        void getOrCreate(TIDR v);
  
  };

main.cpp

  #include "main.h"
  
  // broken with original patch, broken with follow up fix
  template <typename TDM, typename TM, Enums kStrategy>
  template <typename TIDR>
          requires std::is_convertible_v<TIDR, TDM>
  inline void
  DMap<TDM, TM, kStrategy>::getOrCreate(TIDR v) {
  }
  
  // broken with original patch, fixed with follow up fix
  template <typename TDM, typename TM>
  template <typename TIDR>
        requires std::is_convertible_v<TIDR, TDM>
  inline void
  DMap<TDM, TM, Enums::ACCESS>::getOrCreate(TIDR v) {
  }
  
  
  int foo() {
      DMap<int, int> map;
      long i;
      map.getOrCreate(i);
  }


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147722/new/

https://reviews.llvm.org/D147722



More information about the cfe-commits mailing list