Bug 72761 - the "using" keyword has different behaviors
Summary: the "using" keyword has different behaviors
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 5.3.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-31 13:33 UTC by liwei
Modified: 2016-07-31 13:53 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description liwei 2016-07-31 13:33:21 UTC
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;
};
=====================================================================
Comment 1 Jonathan Wakely 2016-07-31 13:53:37 UTC
(In reply to liwei from comment #0)
>     // Code that cannot compile
>     template <typename T>
>     using Check = typename TCur::Layer template <T>;

This is not valid C++, maybe you meant:

    using Check = typename TCur::template Layer<T>;