[LLVMbugs] [Bug 13243] New: Template argument inference problem with template aliases

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Jun 30 02:57:23 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=13243

             Bug #: 13243
           Summary: Template argument inference problem with template
                    aliases
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: slavomir.kaslev at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


The following code compiles fine with "#define BUG 0" but errors with "#define
BUG 1".


#include <tuple>
#include <type_traits>
#include <iostream>

#define BUG 1

#if BUG
template <size_t I>
using size_t_ = std::integral_constant<size_t, I>;
#else
template <size_t I> struct size_t_ {};
#endif

template <class Ch, class Traits, class Tuple, size_t I>
void print_tuple(std::basic_ostream<Ch, Traits>& os, Tuple const& t,
size_t_<I>) {
    print_tuple(os, t, size_t_<I-1>());
    os << ", " << std::get<I>(t);
}

template <class Ch, class Traits, class Tuple>
void print_tuple(std::basic_ostream<Ch, Traits>& os, const Tuple& t,
size_t_<0>) {
    os << std::get<0>(t);
}

namespace std {
    template <class Ch, class Traits, class... Args>
    ostream& operator<<(basic_ostream<Ch, Traits>& os, const tuple<Args...>& t)
{
        os << "[";
        print_tuple(os, t, size_t_<sizeof...(Args)-1>());
        return os << "]";
    }
}

int main() {
    std::cout << std::make_tuple(3.14, 6.28f, "hey you") << std::endl;
    return 0;
}

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list