https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72761

            Bug ID: 72761
           Summary: the "using" keyword has different behaviors
           Product: gcc
           Version: 5.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: liweifriends at gmail dot com
  Target Milestone: ---

The following code is correct:
template <typename T> using Check = std::remove_const<T>;

And the following code is not correct:
template <typename T> using Check = std::remove_const;

However, the following code cannot be compiled
=====================================================================
template <template<typename> class TLayer>
struct SubLayer
{
    template <typename T>
    using Layer = TLayer<T>;
};

template <typename...T> struct SubLayerContainer;

template <typename TOrderedSublayerCont> struct LayerTemp2Type;

template <typename TCur, typename...TSublayers>
struct LayerTemp2Type<SubLayerContainer<TCur, TSublayers...>>
{
    // Code that cannot compile
    template <typename T>
    using Check = typename TCur::Layer template <T>;
};
====================================================================
g++ -Wall -fexceptions --std=c++14 -g --std=c++14  -c
/home/liwei/check/main.cpp -o obj/Debug/main.o
Error: expected ‘;’ before ‘template’

I have to modify the above code as follows to pass the compile:
=====================================================================
template <template<typename> class TLayer>
struct SubLayer
{
    template <typename T>
    using Layer = TLayer<T>;
};

template <typename...T> struct SubLayerContainer;

template <typename TOrderedSublayerCont> struct LayerTemp2Type;

template <typename TCur, typename...TSublayers>
struct LayerTemp2Type<SubLayerContainer<TCur, TSublayers...>>
{
    template <typename T>
    using Check = typename TCur::Layer;
};
=====================================================================

Reply via email to