Coder Social home page Coder Social logo

facebook / fatal Goto Github PK

View Code? Open in Web Editor NEW
969.0 85.0 151.0 2.7 MB

Fatal is a library for fast prototyping software in modern C++. It provides facilities to enhance the expressive power of C++. The library is heavily based on template meta-programming, while keeping the complexity under-the-hood.

Home Page: https://www.facebook.com/groups/libfatal/

License: Other

C++ 99.71% C 0.08% Shell 0.21%

fatal's Introduction

Facebook Template Library Support Ukraine Build Status

Fatal (Facebook Template Library) is a library for fast prototyping software in modern C++.

It provides facilities heavily based on template meta-programming, while keeping most of the complexity under-the-hood, to enhance the expressive power of C++.

Fatal also provides lessons on how to write meta-programs, as well as on how to make the best use of the library, starting at beginner levels.

The goal is make its benefits available to a wider audience other than just hard-core library writers.

Documentation and Examples

A learn-by-example guide is available under the lesson/ directory.

Demo programs are also available under the demo/ directory.

Extensive documentation with examples can be found inline in the source header files.

Building Fatal

Fatal is a header only library, therefore no building is required.

Requirements

A compliant C++14 compiler. Currently tested under Clang {3.5, 3.6, 3.7, 3.8, 3.9, 5.0} and GCC {5, 6}.

There are no other external dependencies.

Links

Discussions group on Facebook

Try it online using Metashell.

Philosophy

Fatal moves fast, therefore it uses the latest and greatest in C++ standards. It aims to adopt new standard features as soon as they're officially out, as long as they provide benefits like performance, productivity and usability improvements.

Stable versions are tagged and can be found under the list of releases. Look out for breaking changes whenever a new release is made (see below) - they should be listed on the release notes.

The master branch is considered the development version of the library and experiences frequent updates. If you want the bleeding edge, that's the branch for you. Be advised, though, that it is under heavy development: breaking changes might be introduced without notice. They'll be tagged with the string [break] in the first line of the commit message.

Installation

There's no need to install Fatal, as long as you add its base directory to the include directories list.

For Clang and GCC, it suffices to either:

  • use the -I path/to/fatal flag
  • set the environment variable CPLUS_INCLUDE_PATH=path/to/fatal

Building Benchmarks and Unit Tests

$ clang++ -Wall -Werror -O2 -std=c++14 -I path/to/fatal \
  -o path/to/output/binary path/to/test/or/benchmark.cpp \

or

$ g++ -Wall -Werror -O2 -std=c++14 -I path/to/fatal \
  -o path/to/output/binary path/to/test/or/benchmark.cpp \

Join the Fatal community

See the CONTRIBUTING file for how to help out.

License

Fatal is BSD-licensed. We also provide an additional patent grant.

fatal's People

Contributors

andrewjcg avatar bdd avatar bigfootjon avatar chadaustin avatar dmitryvinn avatar helfper avatar igorsugak avatar juchem avatar luciang avatar markisaa avatar meyering avatar mizuchi avatar nataliejameson avatar orvid avatar pixelb avatar psaab avatar vitaut avatar willerz avatar yfeldblum avatar yorkz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fatal's Issues

documentation is incorrect for FATAL_STR

From FATAL_STR macro documentation

// this is equivalent to
// using hi = constant_sequence<char, 'h', 'i'>;
FATAL_STR("hi") hi;

But the macro takes the type name as the first argument and is used like FATAL(hi, "hi")

Construct a variant using the value

Right now, to construct a variant we need to create an empty one and them use set or emplace. Why not having a constructor that takes the value directly? We already have it for operator=:

<typename U>
  U &operator =(U const &value)

builtin.h can not compile in VS2015

Sorry, it is non-sense. I withdraw this issue. (however I can not use new VS in my environment, industry is old and stable)
I got a C1001 error. can someone tells me how to avoid it?
at about #60
using __make_integer_seq = typename impl::go...

Lessons failed to compile due to type conflict in fatal/test/string.h

When I tried to compile lessons on Mac OS X with gcc-4.9. I got the following error:

$ g++-4.9 -std=c++11 -I/Users/yinghai/Code/fatal lesson/1.0-variables.cpp -o l1
In file included from /Users/yinghai/Code/fatal/fatal/test/test.h:14:0,
                 from /Users/yinghai/Code/fatal/fatal/lesson/lesson.h:13,
                 from /Users/yinghai/Code/fatal/fatal/lesson/driver.h:13,
                 from lesson/1.0-variables.cpp:10:
/Users/yinghai/Code/fatal/fatal/test/string.h:54:10: error: redefinition of 'struct fatal::detail::string_impl::parse_impl_conversion_pair<std::basic_string<char>, long long int>'
   struct parse_impl_conversion_pair<std::string, From> { \
          ^
/Users/yinghai/Code/fatal/fatal/test/string.h:73:1: note: in expansion of macro 'FATAL_IMPL_PARSE_CONVERSION_PAIR'
 FATAL_IMPL_PARSE_CONVERSION_PAIR(long long);
 ^
/Users/yinghai/Code/fatal/fatal/test/string.h:54:10: error: previous definition of 'struct fatal::detail::string_impl::parse_impl_conversion_pair<std::basic_string<char>, long long int>'
   struct parse_impl_conversion_pair<std::string, From> { \
          ^
/Users/yinghai/Code/fatal/fatal/test/string.h:67:1: note: in expansion of macro 'FATAL_IMPL_PARSE_CONVERSION_PAIR'
 FATAL_IMPL_PARSE_CONVERSION_PAIR(std::int64_t);
 ^
/Users/yinghai/Code/fatal/fatal/test/string.h:54:10: error: redefinition of 'struct fatal::detail::string_impl::parse_impl_conversion_pair<std::basic_string<char>, long long unsigned int>'
   struct parse_impl_conversion_pair<std::string, From> { \
          ^
/Users/yinghai/Code/fatal/fatal/test/string.h:74:1: note: in expansion of macro 'FATAL_IMPL_PARSE_CONVERSION_PAIR'
 FATAL_IMPL_PARSE_CONVERSION_PAIR(unsigned long long);
 ^
/Users/yinghai/Code/fatal/fatal/test/string.h:54:10: error: previous definition of 'struct fatal::detail::string_impl::parse_impl_conversion_pair<std::basic_string<char>, long long unsigned int>'
   struct parse_impl_conversion_pair<std::string, From> { \
          ^
/Users/yinghai/Code/fatal/fatal/test/string.h:71:1: note: in expansion of macro 'FATAL_IMPL_PARSE_CONVERSION_PAIR'
 FATAL_IMPL_PARSE_CONVERSION_PAIR(std::uint64_t);
 ^

The reason for that is https://github.com/facebook/fatal/blob/master/fatal/test/string.h#L73 and https://github.com/facebook/fatal/blob/master/fatal/test/string.h#L74, type long long and unsigned long long are the same as std::int64_t and std::uint64_t. Commenting out these two lines will make things work.

Facebook>Chat panel

There is a bug in facebook in chat, there is a chat panel in right side of facebook page, when there are lots of people are online and that time, if we scroll the scroll bar, then last user are not showing properly.

see the attachment..

screenshot 100

screenshot 100 _3

Compile lesson failed due to some header file missed.

clang++ -o /tmp/.build/clang++/c++11/lesson/1.1-values -O0 -g -pthread -ftemplate-depth-1024 -ftemplate-backtrace-limit=0 -ferror-limit=1 -Wall -Werror -Wextra -std=c++11 -I . lesson/1.1-values.cpp
In file included from lesson/1.1-values.cpp:10:
In file included from ./fatal/lesson/driver.h:13:
In file included from ./fatal/lesson/lesson.h:13:
In file included from ./fatal/test/test.h:15:
In file included from ./fatal/test/string.h:13:
In file included from ./fatal/string/string_view.h:13:
In file included from ./fatal/math/hash.h:13:
In file included from ./fatal/math/numerics.h:18:
In file included from ./fatal/type/traits.h:17:
./fatal/type/data_member_getter.h:112:17: error: no member named 'addressof' in namespace 'std'
return std::addressof(ref(owner));
~~~~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
2 errors generated.

It seems that we miss #include <memory> in /fatal/type/data_member_getter.h
#126

constant_array::data is not constexpr

constant_array::data is not constexpr

fatal/container/constant_array.h:45:54: note: non-constexpr function 'data' cannot be used in a constant expression
  static constexpr value_type const *data() { return get.data(); }
                                                     ^
fatal/type/deprecated/constant_sequence.h:658:50: note: in call to 'data()'
  static constexpr type const *z_data() { return z_array<Suffix...>::data(); }
                                                 ^

Tools: clang-v3.9.0.

Seeing this error when making a library that iterates over the types generated by Thrift static reflection.

Metashell fails on first include statement

Using this configuration I obtain:

> #include <fatal/lesson/lesson.h>                                                                                                    
In file included from <stdin>:1:
In file included from /usr/local/share/metashell/include/fatal_a341e039dc3fd99e331ca8a02e7edbc87d751cb1/fatal/lesson/lesson.h:13:
In file included from /usr/local/share/metashell/include/fatal_a341e039dc3fd99e331ca8a02e7edbc87d751cb1/fatal/test/test.h:14:
In file included from /usr/local/share/metashell/include/fatal_a341e039dc3fd99e331ca8a02e7edbc87d751cb1/fatal/test/string.h:13:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/stdexcept:39:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/string:52:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/basic_string.h:2815:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ext/string_conversions.h:43:
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/cstdio:120:11: fatal error: no member named 'gets' in the global namespa
ce
  using ::gets;
        ~~^
1 error generated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.