GithubHelp home page GithubHelp logo
fatal

facebook / fatal Goto Github PK

View Code? Open in Web Editor NEW
964.0 84.0 138.0 2.73 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

yfeldblum avatar juchem avatar andrewjcg avatar nataliejameson avatar bdd avatar chadaustin avatar dmitryvinn avatar dymk avatar helfper avatar igorsugak avatar meyering avatar bigfootjon avatar luciang avatar markisaa avatar Orvid avatar psaab avatar WillerZ avatar pixelb avatar Mizuchi avatar vitaut avatar YorkZ avatar

Stargazers

James Usevitch avatar  avatar guoyibin avatar  avatar Eric Huynh avatar Rohan Verma avatar Anıl GÜRSES avatar kernelai avatar Neeraj Usadadiya avatar  avatar Z. T. avatar Dennis Fundi avatar  avatar jon m. avatar  avatar day253 avatar Igisid avatar Helder Pereira avatar Kessler D. avatar Matthew Willmering avatar Giorgos E Papadakis avatar Hanyu Wu avatar Vishesh avatar  avatar liu avatar Jerin Philip avatar Jianyu Zhan avatar Jicheng Tang avatar Gianni Hong avatar  avatar Dani avatar  avatar Xuanteng Huang avatar Daniel M avatar Howard Lau avatar Michael  Martin avatar 邓鑫林 avatar 独孤川 avatar Chanjun avatar Jake Zhang avatar Sung Jeon avatar jinho park avatar अविनल कुमार avatar Marcelo Sampaio avatar sun xin avatar Andrew Hamilton avatar dubing avatar Tarun Kumar avatar  avatar Keany Vy KHUN avatar  avatar chaolinyi avatar Nick Fn Blum avatar Shengtuo Hu avatar  avatar  avatar Ho John Lee avatar Simon Hobbs avatar Juan avatar pedoc avatar chanwai1219 avatar Pankesh Bamotra avatar Norman McKeown avatar Linhan Wang avatar Qing Wang avatar assimilator avatar Leo avatar Jonan CM avatar  avatar CanftIn avatar Jeket avatar FredericBRHong avatar Pradeep Kumar avatar lilkypimp1 avatar Pedro Sobota avatar Rijo Joseph C avatar Bartosz Muszarski avatar cihan yesilyurt avatar Amin Yahyaabadi avatar  avatar Enming.Zhang avatar Markus Hihn avatar Nathaniel Reindl avatar linuer avatar Kumar Kartikeya Dwivedi avatar  avatar  avatar Vighnesh Raut avatar  avatar Gabe Madl avatar hhp avatar  avatar Mrinal Dhillon avatar shylock avatar Dmitry Saprykin avatar  avatar codingbull avatar  avatar  avatar Revoori Sai Revanth avatar

Watchers

 avatar Matt Leisinger avatar Vassil Verguilov avatar Jay Feldblum avatar evandrix avatar Rakhmad Azhari avatar Nash Bean avatar Christopher Smith avatar Kasun Thilina avatar Flavio Moreira avatar Prasanna Krishnasamy avatar WangBin avatar Johan Moreau avatar James Cloos avatar  avatar yuan avatar  avatar John Ruffer avatar Jaime Guzman avatar Aaron Kushner avatar Michael Anthony avatar Kimik avatar GP Wang avatar  avatar Nicholas Ormrod avatar HsuehMin Chen avatar John Dunlap avatar blackcat avatar Kai Zhao avatar cjl avatar hemmingway avatar Hacken avatar  avatar Csongor Szabo avatar  avatar Jake Carter avatar Michaël avatar Remo avatar Michael Rayva avatar  avatar Yining Chen avatar Manik Singhal avatar verbalsaint avatar duxin avatar Jéan Thysse avatar Yuchen Xie avatar  avatar MB Parsa avatar chenheng avatar wxthon avatar Fan Wu avatar  avatar Sunil Padmanabhan avatar  avatar Camilo Acosta avatar Aditya Bindal avatar  avatar phantom9999 avatar Chatchai Daecha avatar  avatar Ardy Forouhar avatar Delveri  M. Chick avatar  avatar Benjamin Bourdin avatar danzamerlot avatar  avatar  avatar liuweiguang avatar YongYang avatar fireboy avatar  avatar Tanisha Bhayani avatar Kapil Sharma avatar Philippe Voyer avatar  avatar  avatar  avatar Long avatar Rachel Morrell avatar liu avatar xiaguo avatar  avatar  avatar Nick Fn Blum 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")

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.

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

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.

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.

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)

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

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.