Compile-time reflection in C++1z? [closed]

Reflection use cases are outlined in N3814: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3814.html The general view is that we will do it as an extension of the Type Traits library as exemplified by N3815: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3815.html There are two parts to reflection. The first is introspection. Taking an entity and querying constant values about it. The second is reification, which is … Read more

Is there a std::noncopyable (or equivalent)?

No, because there is a standard way to make a class non-copyable: class MyClass { MyClass(const MyClass&) = delete; MyClass& operator=(const MyClass&) = delete; }: A class that is non-copyable can however be made movable by overloading a constructor from MyClass&&. The declaration to make the class non-copyable (above) can be in the public or … Read more

Should you prefer overloading over specialization of function templates?

Short story: overload when you can, specialise when you need to. Long story: C++ treats specialisation and overloads very differently. This is best explained with an example. template <typename T> void foo(T); template <typename T> void foo(T*); // overload of foo(T) template <> void foo<int>(int*); // specialisation of foo(T*) foo(new int); // calls foo<int>(int*); Now … Read more

numeric_limits lowest and min member functions

Paragraph 18.3.2.4 of the C++11 Standard specifies: static constexpr T min() noexcept; 1 Minimum finite value. 2 For floating types with denormalization, returns the minimum positive normalized value. 3 Meaningful for all specializations […] static constexpr T lowest() noexcept; 6 A finite value x such that there is no other finite value y where y … Read more

Why is this cast to bool required?

The reason is that just writing !pred(*first) could result in a call to an overloaded operator! rather than the call to explicit operator bool. It’s interesting that this measure was taken for pred, but an overloaded operator&& can still be selected in the implementation provided. first != last would need to be changed to bool(first … Read more

When should I use std::bind?

Here’s something you can’t do with a lambda: std::unique_ptr<SomeType> ptr = …; return std::bind(&SomeType::Function, std::move(ptr), _1, _2); Lambdas can’t capture move-only types; they can only capture values by copy or by lvalue reference. Though admittedly this is a temporary issue that’s being actively resolved for C++14 😉 “Simpler and clearer” is a matter of opinion. … Read more

What are the differences amongst Python’s “__get*__” and “_del*__” methods?

The documentation for every method that you listed is easly reachable from the documentation index . Anyway this may be a little extended reference: __get__, __set__ and __del__ are descriptors “In a nutshell, a descriptor is a way to customize what happens when you reference an attribute on a model.” [official doc link] They are … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)