Category "c++11"

Tensorflow Op: how to include libtensorflow_framework.so?

I followed the instructions of this tutorial: https://www.tensorflow.org/extend/adding_an_op#implement_the_gradient_in_python. There is this comment provided: g

Why is "std::is_pointer<std::nullptr_t>::value" equal to false?

I read about std::is_pointer in C++. Then I wrote the program and check whether T is a pointer type or not using std::is_pointer. #include <iostream> i

Is it legal to define an anonymous struct?

Is the following code legal?: struct { int x; }; This code simply defines an unnamed structure. I do not intend to create objects of this type, nor do I

<command-line>:0:3: warning: ISO C++11 requires whitespace after the macro name

I am compiling qt sources (C++) on different version of Ubuntu OS (14.04 and 16.04 LTS). The sources compile (g++) on 14.04 LTS without warnings. But on 16.04 g

C++: What is the correct cast for offseting to std::vector iterator?

I have a function that takes a std::vector of doubles, and copies them to another vector, but at a particular offset (assume there is sufficient space): void c

Keep getting error message not all control paths return a value

bool isEnemy(const string& check) { if (check == enemy1 || check == enemy2 || check == enemy3) // if the name being checked is an enemy of this kni

Cache-friendliness std::list vs std::vector

With CPU caches becoming better and better std::vector usually outperforms std::list even when it comes to testing the strengths of a std::list. For this reason

Advantage of using trailing return type in C++11 functions

What is the advantage of specifying a trailing return type in C++11, as opposed to a normal return type? Look at foo1 vs foo2 here: int foo1() { return 1;

How to apply Shamir's Secret Sharing on strings passwords

I was trying to write a simple code to generate and obtain passwords using Shamir's secret sharing method. My question is: How can I apply this to string passwo

do sequentially-consistent atomic loads (load-load pair) form an inter-thread synchronisation point?

I am trying to understand what does sequentially-consistent ordering mean for loads. Consider this artificial example: #include <atomic> #include <thr

How to avoid the need to specify deleter for std::shared_ptr every time it's constructed or reset?

std::unique_ptr has 2 template parameters, the second of which is the deleter to be used. Thanks to this fact, one can easily alias a unique_ptr to a type, whic

Why do std::stof, std::stod, and std::stold handle errors with exceptions?

What is the rationale for why std::stof, std::stod, and std::stold throw exceptions? http://en.cppreference.com/w/cpp/string/basic_string/stof Input errors are

Is it safe to init a std::unique_ptr from a local raw pointer?

I know it's unwise to do so with a std::shared_ptr. But what about std::unique_ptr? E.g. : class A { public: void do_something() { } }; std::vector<std::

How can I generate a tuple of N type T's?

I want to be able to write generate_tuple_type<int, 3> which would internally have a type alias type which would be std::tuple<int, int, int> in thi

How does const auto and auto const apply to pointers?

I was try out some code and am wondering how the const qualifier in C++ applies to pointer types when using auto. int main() { int foo = 1; int bar = 2;

print the unordered map values when key value is given as input

I have written the code to read the string values and mapped as key and value. Now I am facing issue in printing the values, if we have given key value as input

C++ E0147 declaration is incompatible with static object

Websource.hpp #ifndef WEBSOURCE_HPP #define WEBSOURCE_HPP #pragma once class Colour { public: unsigned char _ucRed; unsigned char _ucGreen; unsign

Modern pattern to write custom ostream operator

Typically, in C++, we used to define a custom ostream operator<< this way: class A { int impl_; friend std::ostream& operator<<(std::ost

const& , & and && specifiers for member functions in C++

Recently I was reading through the API of boost::optional and came across the lines: T const& operator *() const& ; T& operator *() & ; T

How to specify -std=c++11 option in bazel BUILD file?

How to add this option into a target description section? Thanks.