rapptz / gears Goto Github PK
View Code? Open in Web Editor NEWC++ Utilities
Home Page: http://rapptz.github.io/Gears/docs/
License: MIT License
C++ Utilities
Home Page: http://rapptz.github.io/Gears/docs/
License: MIT License
A module that would contain functional things such as currying, higher-ordered functions and maybe some LINQ-like stuff. Probably based on Lia but improved upon or changed to match the API.
Things that help with std::basic_string
like:
trim
, trim_left
, trim_right
, etcjoin
split
left
, right
reverse
iequal
, istart_with
, iend_with
, start_with
, end_with
, all
, contains
, etcreplace_first
, replace_last
, replace_nth
, replace_all
erase_first
, erase_last
, erase_nth
, erase_all
find_first_of
, first_last_of
, etc.to_upper
, to_lower
, etc_s
literal provided to ease building of std::string
.std::stringstream
).Another homage to Boost. This time a C++11 aware variant
. I'm leaning on putting this under the utility module. Having it in its own module would be conflicting with the current naming standards set in, as it'd make it gears::variant::variant
which is awfully redundant. An exception to the rule could be made so it'd end up being gears::variant
but I'm not too convinced.
Basic meta programming module that contains the following:
std::tuple
is a poor man's type list. A better alternative should exist in gears. Maybe called gears::meta::list
which would be similar to boost::mpl::vector
I suppose.
It might be a good idea to have a new module, i.e. system, that would handle certain cross platform things such as process IDs, subprocess, etc. At the moment I'm not too keen on the idea but it's worth thinking about in the future.
There are a lot of unnecessary null checks in fprint.h, for example (not all):
Line 37 in c04125d
Line 101 in c04125d
Potential issue: format string is totally ignored if no additional arguments were passed. You mentioned this was by design, but I strongly recommend you to reconsider it as it potentially breaks generic code that relies on fprint, and if a user really wants the faster "unformatted formatting" they can always resort to just calling out << str
.
Doc issue: format-string
is a confusing identifier in your grammar since you have the format string, containing literal text and format-string
s. See the issue? I suggest taking over Pythons terminology and calling it a "replacement field".
Critical issue: formatting is not stateless, as you do not correctly set default fill parameters, and they can carry over from replacement field to replacement field. For example: https://gist.github.com/orlp/a0aba247345baaf8c393 I only checked this for fill, but the same probably applies to precision, align, width and potentially more.
Checking issue: you do not check if an integer came after the dot in ["." precision]
. An example invalid format string that you do not throw an exception on is |:.|
Missing feature: std::hexfloat
- you said GCC didn't support this, but I list it here for completion anyway.
Missing feature: std::showpoint
- I suggest changing p
to std::showpoint
and assigning +
to std::showpos
.
For ideas of how I solved some of these problems/set up my solution see https://github.com/orlp/libop/blob/master/bits/io.h .
Set up some unit tests and link it to travis-ci.
Subnamespacing will be ideal for the following reasons:
namespace gx = gears::stuff;
using namespace gears::stuff
without dragging the entire gears
namespace.gears::modone::f(10)
would be different from gears::modtwo::f(10)
.Current plans would be to have this be consistent with the module it's imported in. e.g. in the strings module everything would be gears::string
Subnamespacing is already in use with gears::literals
and gears::operators
. Changes would have to include deeper subnamespacing, e.g. gears::string::literals
and gears::string::operators
.
This follows the convention of Boost.
A form of type erasure.
maybe<T>
should undergo the same process that happened with Gears.Meta. A rename to fit the standard amongst other things. This is a breaking change.
maybe<T>
to optional<T>
nothing
to nullopt
just
to make_optional
optional<T&>
optional<optional<T>>
There's a crash when you do --help
with the default formatter due to bad handling of indentation.
The code does something like this:
auto&& max_name = std::max_element(opts.begin(), opts.end(), [](const option& lhs, const option& rhs) {
return lhs.name < rhs.name;
});
But this just gets the maximum in terms of lexicographical order, so e.g. verbose
will be higher than myreallylongname
due to the lexicographical comparison.
The fix is simple, just use lhs.name.size()
to get the actual size instead.
This is a breaking change.
Since C++14 got accepted, the (unfortunate) naming of template aliases has been standardised and it's best to be consistent with the standard. I propose the following renames:
Type<T>
-> eval<T>
PascalCase
to snake_case_t
And
-> all
Or
-> any
Not
-> negate
If
-> if_
LazyIf
-> lazy_if
Const
-> constant
Integer
-> integer
PascalCase
to snake_case
.indices
follow the C++14 standard naming.PascalCase should be reserved for concepts only.
At the moment, the concepts module is pretty messy. Lots of small traits that compose, some aren't exactly right, many are just ThisCase
version of existing type traits without actually being part of the concept. Maybe it's time to clean up concepts into something a little more sane. People using the library have no sane way of defining their own traits as the documentation is scarce and only the provided ones are sane enough to use. Building blocks would be nice to have to maul over the impending release of C++1z.
At the moment I do #include "../stuff/file.hpp"
when I should be using #include <gears/stuff/file.hpp>
instead. single.py
will have to be modified to take this into account too.
Modernisation of Boost.Operators with no compiler work-arounds and possibly (somehow?) constexpr
. Sub-namespacing is another problem with this one, albeit minor. At the moment the sub-sub-namespace operators
is used for operators to inject to the global namespace. This shouldn't be an issue with the sub-namespace though.
Stuff for <chrono>
.
Such as:
Maybe in the future there will be more in the Chrono module, but as of now that's all there is.
Something to represent an optional value I suppose. It's similar to Boost.Optional but not really since it'll disallow references. This will be part of C++14 soon but it's a good addition to gears.
One of the first things I have wanted to do when remaking Gears was to provide documentation as I went along, however this didn't happen. By the time I get around to Issue #11 documentation will probably be worked on. It'll use Doxygen.
At the moment, the meta module is really messy. Everything is lodged into alias.hpp
or meta.hpp
with little to no in between.
Possible solutions that are open to consideration:
if.hpp
, and.hpp
, etc.Such as:
Math stuff:
-1
for "infinite" precisionpi<double>()
)Itertools!
Inspired by a post on reddit and just something I've generally always wanted to do.
Based on these itertools. But here they are for listing sakes.
I'm not really satisfied with the way documentation is done. There isn't too much I could do since it's Doxygen. Doxygen makes a separate page for every struct and class so it doesn't work very well for documentation of metaprogramming facilities. Something like how Boost.MPL does its documentation might be better.
Some ideas to throw around to improve meta documentation:
std::integral_constant
.::type
or ::value
.SCons is a bit of a pain in the ass. I've migrated everything else to ninja, and might as well do it for Gears too.
The C++14 Filesystem TS has been published. That means it's probably a good time to make an implementation of it. The TS could be found here.
Command line parsing utility. Something akin to Boost.ProgramOptions except in modern C++11.
Containers that are useful would be nice to have. The new module could also contain utilities that aid the usage of the C++ standard containers, such as allocators.
std::vector
.static_vector
flat_set
flat_map
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.