CppCast Episode 116: Volta and Cuda C++ with Olivier Giroux

Episode 116 of CppCast the only podcast for C++ developers by C++ developers. In this episode Rob and Jason are joined by Olivier Giroux from NVidia to talk about programming for the Volta GPU.

CppCast Episode 116: Volta and Cuda C++ with Olivier Giroux

by Rob Irving and Jason Turner

About the interviewee:

Olivier Giroux has worked on eight GPU and four SM architecture generations released by NVIDIA. Lately, he works to clarify the forms and semantics of valid GPU programs, present and future. He was the programming model lead for the new NVIDIA Volta architecture. He is a member of WG21, the ISO C++ committee, and is a passionate contributor to C++'s forward progress guarantees and memory model.

Visual Studio extensions for C++ developers in Visual Studio 2017—Adam Welch

Several Visual Studio extensions that can make your life better as a C++ developer:

Visual Studio extensions for C++ developers in Visual Studio 2017

by Adam Welch

From the article:

In this blogpost we want to highlight several Visual Studio extensions that can make your life better as a C++ developer if you’re using Visual Studio 2017 or considering upgrading...

Quick Q: Array Initialisation Compile Time - Constexpr Sequence

Quick A: Use integer_sequence with a helper function.

Recently on SO:

Array Initialisation Compile Time - Constexpr Sequence

1) How to implement that kind of integer_sequence?

template <std::size_t... Is>
constexpr auto make_sequence_impl(std::index_sequence<Is...>)
    return std::index_sequence<generate_ith_number(Is)...>{};

template <std::size_t N>
constexpr auto make_sequence()
    return make_sequence_impl(std::make_index_sequence<N>{});

2) Is it possible to build an std::array from that integer_sequence at compile time?

template <std::size_t... Is>
constexpr auto make_array_from_sequence_impl(std::index_sequence<Is...>)
    return std::array<std::size_t, sizeof...(Is)>{Is...};

template <typename Seq>
constexpr auto make_array_from_sequence(Seq)
    return make_array_from_sequence_impl(Seq{});


int main()
    constexpr auto arr = make_array_from_sequence(make_sequence<6>());
    static_assert(arr[0] == 0);
    static_assert(arr[1] == 1);
    static_assert(arr[2] == 2);
    static_assert(arr[3] == 4);
    static_assert(arr[4] == 5);
    static_assert(arr[5] == 7);

Quick Q: vector of vector does not convert brace encloser list

Quick A: The constructor needs an extra {} pair.

Recently on SO:

vector does not convert brace encloser list

You have two options:

  1. add a constructor taking std::initializer_list<std::initializer_list<T>>
  2. eclose the init expression with another set of {} i.e.
Matrix<double> a{{

    { 17,    24,    1},

    { 23,    5,     7 },

    {  4,     6,    13 }


Ok, I'll try a little explanation of what is going on here:

If there is no constructor taking a std::initializer_list then the outermost {} are always opening and closing the constructor call if you will, and not part of what you actually pass to the constructor.

Matrix<double> a{ {1, 2}, {3, 4} };
                ^ ^~~~~~~~~~~~~~ ^
                |  2 parameters  |
                |                |
                |                |
            opening            closing

As you can see this is taken as a constructor with 2 parameters, in this case 2 initializer_lists.

This is why you need another set of {}:

Matrix<double> a{ {{1, 2}, {3, 4}} };
                ^ ^~~~~~~~~~~~~~~~ ^
                |  1 parameter     |
                |                  |
                |                  |
            opening            closing

In order for the outermost {} to be considered an initializer_list then the constructor needs to have an overload taking a initializer_list. That is what is happening in the std::vector case.

CppCon 2016: The Exception Situation—Patrice Roy

Have you registered for CppCon 2017 in September? Don’t delay – Registration is open now.

While we wait for this year’s event, we’re featuring videos of some of the 100+ talks from CppCon 2016 for you to enjoy. Here is today’s feature:

The Exception Situation

by Patrice Roy

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

Exceptions have been a part of C++ for a long time now, and they are not going away. They allow programmers to concentrate on the meaningful parts of their code and treat the things that happen infrequently as… well, exceptional situations, to be dealt with when and where the context makes it reasonable or useful.

On the other hand, some significant parts of the C++ programming community either dislike this mechanism or outright reject it, for a number of reasons. Work in SG14 has raised performance issues in some cases; there are those who dislike the additional execution paths introduced in programs that rely on exceptions; some programmers raised issues with respect to exceptions and tooling, integration with older codebases, writing robust generic code, etc.

This talk will be neither for not against exceptions. It will present a perspective on cases where they make sense, cases where they are less appropriate, alternative disappointment handling techniques presented along with client code in order to show how the various approaches influence the way code is written. Performance measurements will be given along the way. Some creative uses of exceptions will also be presented in order to spark ideas and discussions in the room.

Useful Improvements in the PVS-Studio 6.17 Release

In this version there are improvements, which, in my opinion, deserve a small note.

Useful Improvements in the PVS-Studio 6.17 Release

by Andrey Karpov

From the article:

A much more interesting feature is that a mechanism of virtual values was significantly redesigned in the kernel of C++ analyzer. For example, now the analyzer performs a double loop passage, which allows it to define the range of possible values of variables, changing in a loop, more accurately. So don't be surprised if the analyzer starts issuing many warnings for that code which used to seem correct for the analyzer.