[cfe-dev] [libc++] std::count with bool types

Howard Hinnant hhinnant at apple.com
Thu May 10 07:03:42 PDT 2012


Sorry about that!  Somehow some friend statements were missing.  Fix committed revision 156543.

Thanks for the report!

Howard

On May 10, 2012, at 9:41 AM, Michael Sommerville wrote:

> I am trying out a recent clang 3.1 release candidate on Linux with and
> ToT libc++ and have run into the following compilation error. This
> test builds successfully using libstdc++:
> 
> $ clang -v
> clang version 3.1 (branches/release_31 155817)
> Target: x86_64-unknown-linux-gnu
> Thread model: posix
> .
> $ cat test_count.cxx
> #include <iostream>
> #include <algorithm>
> #include <vector>
> 
> int main ()
> {
>    // counting boolean elements in array
>    bool bool_array[] = { true,false,true,false,true,false,true,true};
>    int mycount = (int) std::count (bool_array, bool_array+8, true);
>    std::cout << "true appears " << mycount  << " times.\n";
> 
>    // counting boolean elements in container
>    std::vector<bool> bool_vector( bool_array,bool_array+8 );
>    mycount = (int) std::count (bool_vector.begin(), bool_vector.end(), false);
>    std::cout << "false appears " << mycount  << " times.\n";
> }
> 
> $ clang++ -stdlib=libc++ test_count.cxx -o testit
> In file included from test_count.cxx:1:
> In file included from /usr/include/c++/v1/iostream:40:
> In file included from /usr/include/c++/v1/istream:156:
> In file included from /usr/include/c++/v1/ostream:134:
> In file included from /usr/include/c++/v1/bitset:120:
> /usr/include/c++/v1/__bit_reference:236:27: error: '__storage_type' is
> a private member of
>      'std::__1::__bit_iterator<std::__1::vector<bool,
> std::__1::allocator<bool> >, false, 0>'
>    typedef typename _It::__storage_type __storage_type;
>                          ^
> /usr/include/c++/v1/__bit_reference:299:16: note: in instantiation of
> function template specialization
>      'std::__1::__count_bool_true<std::__1::vector<bool,
> std::__1::allocator<bool> > >' requested here
>        return __count_bool_true(__first, static_cast<typename
> _Cp::size_type>(__last - __first));
>               ^
> test_count.cxx:14:21: note: in instantiation of function template
> specialization 'std::__1::count<std::__1::vector<bool,
>      std::__1::allocator<bool> >, bool>' requested here
>    mycount = (int) std::count (bool_vector.begin(), bool_vector.end(), false);
>                    ^
> /usr/include/c++/v1/__bit_reference:1071:84: note: declared private here
>    typedef typename _Cp::__storage_type
>            __storage_type;
> 
>            ^
> /usr/include/c++/v1/__bit_reference:238:50: error: '__bits_per_word'
> is a private member of
>      'std::__1::__bit_iterator<std::__1::vector<bool,
> std::__1::allocator<bool> >, false, 0>'
>    static const unsigned __bits_per_word = _It::__bits_per_word;
>                                                 ^
> /usr/include/c++/v1/__bit_reference:1074:27: note: declared private here
>    static const unsigned __bits_per_word = _Cp::__bits_per_word;
> 
> etc etc
> 
> -Michael
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list