Comments (6)
Done. It wasn't as simple to implement as you suggested, as string_sort requires an unsigned wchar_t, but it works now by splitting the wrapper into 2 enable_ifs, each with its own unsigned character type (wchar_t is signed).
from sort.
Ok, I didn't know about the unsigned wchar_t
. To be honest, the library I am writing is 90% indirection & code architecture and 10% actual sorting logic if we exclude the algorithms that I didn't write, so I don't understand how some of the algorithms work (including this one), hence the bad suggestion, sorry for that.
Anyway, I didn't have many tests for std::wstring
but they are passing with this fix. Thanks :)
from sort.
You're welcome.
from sort.
Oops, seems that I spoke too soon. For some reason I totally missed a warning introduced by the fix:
With g++:
warning: long, short, signed or unsigned used invalidly for 'unused' [-Wpedantic]
With clang++:
warning: 'wchar_t' cannot be signed or unsigned [-Wpedantic]
It seems like wchar_t
shouldn't be declared unsigned
, and it's true that its signedness is undefined by the standard. Would std::make_unsigned<wchar_t>::type
(or a Boost equivalent) solve the problem?
from sort.
On Sun, Sep 20, 2015 at 8:06 AM Morwenn [email protected] wrote:
Oops, seems that I spoke too soon. For some reason I totally missed a
warning introduced by the fix:With g++:
warning: long, short, signed or unsigned used invalidly for 'unused'
[-Wpedantic]With clang++:
warning: 'wchar_t' cannot be signed or unsigned [-Wpedantic]
It seems like wchar_t shouldn't be declared unsigned, and it's true that
its signedness is undefined by the standard. Would
std::make_unsigned<wchar_t>::type (or a Boost equivalent) solve the
problem?While resolving this issue, I ran into another complication I'd forgotten
about: wchar_t is 2 bytes on Windows, and 4 bytes on linux. 2 bytes sorts
nicely with the string_sort approach, but 4 bytes requires breaking up the
characters into pieces and feeding them to the algorithm, a bit of
complication I'm not ready to stick into the core library. Internally
string_sort handles characters of over 2 bytes that aren't being managed by
custom functors by just falling back to std::sort and issuing a
compile-time warning.
So my solution was:
Enable spreadsort for 2-byte wstrings (using uint16_t as the unsigned
character type), and update the documentation to make it clear that it
doesn't work for 4-byte wstrings. I've rolled this change out to master,
and reverted my wstring testing change, as testing std::sort of wstring
vectors on linux is just silly.
Bottom line: sorting wstrings with spreadsort on linux just isn't going to
work for you unless you're willing to write your own functors. For your
application, I think just skipping spreadsort wstring support should be
fine.
from sort.
Ok, I think I understand the problem a bit better, thanks for the explanation. I guess I'll just skip the std::wstring
support for now as you suggest, or SFINAE it out when the character width is greater than 2 bytes.
from sort.
Related Issues (20)
- Missing parallel_stable_sort with comparator and thread count HOT 3
- tests take too long to complete on variant=debug HOT 1
- Compile failure when usign togerther with range/algorithm HOT 1
- Constants should be policy-based HOT 3
- Fix annoying warnings HOT 2
- error in common/spinlock.hpp HOT 5
- spinsort and flat_stable_sort don't compile with -fno-exceptions or -fno-operator-names GCC flags HOT 12
- Missing documentation HOT 2
- segfault with parallel_stable_sort and 100000 entries HOT 3
- std::return_temporary_buffer HOT 2
- fatal error: 'boost/type_traits.hpp' file not found HOT 2
- boost/sort/block_indirect_sort/block_indirect_sort.hpp doesn't compile under VS2017 HOT 8
- pivot.hpp std::size_t fix HOT 3
- boost/sort/common/util/insert.hpp #includes itself HOT 3
- Broken boost::sort::spreadsort::string_sort HOT 3
- Document usage of pdqsort HOT 4
- spreadsort support for wider integers (e.g., (unsigned) __int128) HOT 3
- Additional memory specification does not seem to consider the index for block indirect sort HOT 5
- Potential undefined behavior in float_sort.hpp HOT 2
- Explicit calls to `std::swap` are made on user provided template types. This does not work for `C++20`. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sort.