Coder Social home page Coder Social logo

brigand's People

Contributors

alexhuszagh avatar ccharly avatar edouarda avatar gregorburger avatar jfalcou avatar jonathanpoelen avatar mkurdej avatar nilsdeppe avatar nilsvu avatar odinthenerd avatar rolandschulz avatar vrichter avatar weshoke avatar whoshuu avatar wthrowe 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

brigand's Issues

brigand set

shoudl support insert remove contains

idea is to have simialr thing than map but with a contains static member that return true_ if the key match

key `void` not supported in map

void and other non default constructible type cannot be key of map:

changing in map.hpp

template <typename T>
struct Type {};

// fastlane for constant amortized time
template <class T0>
struct map_impl<T0>
{
    static typename T0::second_type at(Type<typename T0::first_type>);

    template <typename U>
    static no_such_type_ at(U) {}
};

// .. other fastlane

template <typename M, typename K>
struct lookup
{
    using type = decltype(M::at(std::declval<Type<K>>())); // or using type = std::result_of_t<M::at(Type<K>)>;
};

and in at.hpp

template <typename T>
struct has_at_method
{
    struct dummy {};
    template <typename C, typename P>
    static auto test(P*) -> decltype(static_cast<void>(C::at(std::declval<Type<P>>())) /*cast to handle comma operator */, std::true_type());

    // previous false case + bool value
};

solves that.

broken for_each with evil comma operator

The following doesn't compile:

#include <brigand/sequences/list.hpp>
#include <brigand/algorithms/for_each.hpp>

struct evil
{
  template< typename U > evil& operator()(U ) const {  return *this;  }

  evil& operator, (int) { return *this; } // evel operator coma
};

void for_each_test()
{
  brigand::for_each< brigand::list<char,short,int,double> >( evil{} );
}

fix is to change: return (void)std::initializer_list<int>{(std::ref(f)((Ts&&)a),0)...}, f;

into

return (void)std::initializer_list<int>{(static_cast<void>(std::ref(f)((Ts&&)a)),0)...}, f;

or

return (void)std::initializer_list<int>{(std::ref(f)((Ts&&)a), void(), 0)...}, f;

BTW, for (Ts&&) a, g++ 4.9.2 produces following warning:
brigand/algorithms/for_each_args.hpp:15:64: warning: use of old-style cast [-Wold-style-cast]

Implement quote

quote turn template<typename...> struct F into a apply based metafunction class

Note about SFINAE and static_assert in as_pair

Not really a issue, but due to static_assert (and type) in struct pair_wrapper
SFINAE doesn't occurs and following doesn't compile:

template <typename... Ts>
auto can_use_as_pair_impl(int)
-> decltype(typename brigand::as_pair<brigand::list<Ts...>>::type{}, std::true_type{});

template <typename... Ts>
std::false_type can_use_as_pair_impl(...);

template<typename... Ts>
using can_use_as_pair = decltype(can_use_as_pair_impl<Ts...>(0));

static_assert(std::is_same<std::true_type, can_use_as_pair<int, int>>::value, "error in brigand::as_pair");
static_assert(std::is_same<std::false_type, can_use_as_pair<int, int, int>>::value, "error in brigand::as_pair");

repeat<Functor,N>

Simply put:

 brigand::repeat<F,N,T> =  brigand::repeat<F,N-1,F<T>>; 
 brigand::repeat<F,1,T> = F<T>;
 brigand::repeat<F,0,T> = T;

and of course, fast-lane

How to write meta-function combiner

Let's say i want to write compose<F,G> that gimme something akin to F<G> when applied to T.
or the negation fo a meta-function ?

Looks to me the syntax is not clear (see nope in all implementation).

Invalid brigand/brigand.hpp

#include are invalid:

  • s are missing for most directory (#include <brigand/algorithm/apply.hpp> should be #include <brigand/algorithms/apply.hpp>...)
  • some files are misplaced: size.hpp is in sequences, not algorithm.

As there is no forward declaration for boost::variant, boost/variant is required before include brigand.hpp :(.

brigand::any is buggy

// this doesn't pass and should
static_assert(brigand::any<brigand::integral_list<int, 1, 1, 1, 1>>::value, "invalid any list");

// this pass and should not
static_assert(brigand::any<brigand::integral_list<int, 0, 0, 0, 0>>::value, "invalid any list");

Any is not !all

last_element improvement

It can be rewritten as

template <class... Ts>
using last_element = decltype(type_<Ts>...)::type;

Maybe add a layer for a better message for 0-size.

Add contributors

Hey guys, you've been many to have contributed to brigand, if you'd like to be listed as a contributor let me know here.

Duplicate in map.

Duplicates in map key are only handled within the fastlane.

so

using big_map = brigand::map<
    brigand::pair<type_one, int>,
    brigand::pair<type_two, type_one>,
    brigand::pair<type_three, type_two>,
    brigand::pair<type_four, type_three>,
    brigand::pair<type_five, type_four>,
    brigand::pair<type_six, type_five>,
    brigand::pair<type_seven, type_six>,
    brigand::pair<type_eight, type_seven>,
    brigand::pair<type_one, type_eight> // Duplicate
 >;

is a valid type whereas if we remove brigand::pair<type_eight, type_seven>,, we correctly have compile error.

Implement bind

bind<F,....> takes a metafunction class and chanegs its parameters

warnings under gcc

lot of warning for no return statement in map.hpp (whereas definition is not needed)

brigand/sequences/map.hpp:20:37: warning: no return statement in function returning non-void [-Wreturn-type]
static no_such_type_ at(U) {}

just replace by

 static no_such_type_ at(U);

brigand/algorithms/for_each_args.hpp:15:82: warning: use of old-style cast [-Wold-style-cast]
return (void)std::initializer_list{(static_cast(std::ref(f)((Ts&&)a)),0)...}, f;

Replace by std::forward<Ts>(a) (or by static_cast<Ts&&>(a)).

Add a static assert to make_pair

I think a static_assert on the size (ie you can't make a pair if your sequence is greater than 2) can help a lot in more complex metaprograms and it's very easy to do

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.