[cfe-dev] Fixes to partial ordering break Boost.Hana

Pavel A. Lebedev via cfe-dev cfe-dev at lists.llvm.org
Mon Jan 9 15:20:38 PST 2017


Hi.

Commit r290511 "Fix some subtle wrong partial ordering bugs particularly
with C++1z auto-typed non-type template parameters"
seems to break some template specialization tricks at the core of Boost.Hana
library.
The reduced example is:

$ cat hana.cpp

// SFINAE helpers.

template<bool Condition>
struct when;

template<typename...>
struct is_valid
{
    static constexpr bool value = true;
};

// A class and its tag.

struct c_tag;

struct C
{
    using tag = c_tag;
};

// Tag getter. When a type has a nested type "tag", it specifies its tag.
// When it doesn't have one, the tag is type itself.

template<typename T,typename = void>
struct tag_of : tag_of<T,when<true>> {};

template<typename T,bool Condition>
struct tag_of<T,when<Condition>>
{
    using type = T;
};

template<typename T>
struct tag_of<T,when<is_valid<typename T::tag>::value>>
{
    using type = typename T::tag;
};

// Attempt to calculate tag of C.

using tag_of_c = typename tag_of<C>::type;


$ clang++ -std=c++14 -fsyntax-only hana.cpp

hana.cpp:25:17: error: ambiguous partial specializations of 'tag_of<C,
when<true> >'
struct tag_of : tag_of<T,when<true>> {};
                ^
hana.cpp:41:27: note: in instantiation of template class 'tag_of<C, void>'
requested here
using tag_of_c = typename tag_of<C>::type;
                          ^
hana.cpp:28:8: note: partial specialization matches [with T = C, Condition =
true]
struct tag_of<T,when<Condition>>
       ^
hana.cpp:34:8: note: partial specialization matches [with T = C]
struct tag_of<T,when<is_valid<typename T::tag>::value>>
       ^
1 error generated.


Is this a problem with the library or clang?

--- 
Pavel A. Lebedev




More information about the cfe-dev mailing list