Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is there overdesign in friend template functions or a Bug in gcc? #11

Open
viboes opened this issue Sep 16, 2017 · 0 comments
Open

is there overdesign in friend template functions or a Bug in gcc? #11

viboes opened this issue Sep 16, 2017 · 0 comments

Comments

@viboes
Copy link

viboes commented Sep 16, 2017

Wondering if the definition of friend template functions as in

template <class T>

doesn't implies a double definition.

clang 4.0.0 works ,but I'm getting in my implementation while compiling with gcc-6.1 the following

../include/experimental/fundamental/v3/bits/bit_pointer.hpp : dans l'instantiation de ‘class std::experimental::fundamental_v3::bit_pointer<short unsigned int>’ :
../include/experimental/fundamental/v3/bits/bit_iterator.hpp:51:79:   required from ‘class std::experimental::fundamental_v3::bit_iterator<std::_List_iterator<short unsigned int> >’
../example/bits/bit.cpp:104:94:   required from here
../include/experimental/fundamental/v3/bits/bit_pointer.hpp:187:40: erreur: redefinition of ‘template<class T> constexpr std::experimental::fundamental_v3::bit_pointer<WordType> std::experimental::fundamental_v3::operator+(typename std::experimental::fundamental_v3::bit_pointer<WordType>::difference_type, std::experimental::fundamental_v3::bit_pointer<WordType>)’
       friend constexpr bit_pointer<T> operator+(
                                        ^
../include/experimental/fundamental/v3/bits/bit_pointer.hpp:187:40: note: ‘template<class T> constexpr std::experimental::fundamental_v3::bit_pointer<WordType> std::experimental::fundamental_v3::operator+(typename std::experimental::fundamental_v3::bit_pointer<WordType>::difference_type, std::experimental::fundamental_v3::bit_pointer<WordType>)’ previously defined here
../include/experimental/fundamental/v3/bits/bit_pointer.hpp:198:15: erreur: redefinition of ‘template<class T, class U> constexpr typename std::common_type<typename std::experimental::fundamental_v3::bit_pointer<WordType>::difference_type, typename std::experimental::fundamental_v3::bit_pointer<U>::difference_type>::type std::experimental::fundamental_v3::operator-(std::experimental::fundamental_v3::bit_pointer<WordType>, std::experimental::fundamental_v3::bit_pointer<U>)’

Is this a bug in clang/gcc?

Why the following is not enough?

      friend constexpr bit_pointer operator+(
          difference_type n,
          bit_pointer x
      )

IMHO the constructor takes care already of the valid conversions, so even the mixed comparison should work directly with bit_pointer without needed bit_pointer<T> and bit_pointer<U>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant