containers

Docker mount a volume as root

╄→гoц情女王★ 提交于 2019-12-22 14:04:41
问题 The problem description I have a Docker image, which is being executed with volume mounting options a large number of times. It is built in a way so that the default user does not have root permissions. However I need to make sure that when I mount the volume it is being mounted as root and not as the current working user because of security concerns. (The current working non-root user must not be allowed to delete any files inside the mounted volume.) Example From the host machine: docker

std::string a container

淺唱寂寞╮ 提交于 2019-12-22 11:49:30
问题 Is std::string a container class in standard c++ library, restricted to hold only char elements? 回答1: It's a typedef of std::basic_string<char> , actually. std::basic_string is a container class specifically designed for string operations. This container can be used for wide characters ( wchar_t ) as well; for that case its typedef would be wstring . 回答2: A std::basic_string<> is a class that is very much like a sequence container. Note that std::basic_string can contain any POD type, not

Decrypt with gpg from inside a docker container

不想你离开。 提交于 2019-12-22 11:20:01
问题 I have an encrypted file with gpg that I want to decrypt from inside a docker container. gpg is not found on the container, how would I add it. 回答1: Depending on your base image (used by your container), you would need to add to your Dockerfile (or to make one, starting with FROM <the image used by your container> ) with: RUN apt-get update && apt-get install gnupg (as in this docker-vault-init Dockerfile) Then check out "Adding GPG key inside docker container causes “no valid OpenPGP data

Integer index-able RAII container for non-copyable type

不想你离开。 提交于 2019-12-22 08:55:42
问题 Is there a standard container that has the same general API as vector<T> but that populates new locations via direct default construction? Background: I have a type that disallows copying but has a default constructor and what I really want to do is this: vector<NoCopy> bag(some_size); // use bag[i]'s return; // bag & contents get correctly cleaned up. However, this doesn't work because vector<T>(int) is implemented in terms of default constructing an object and then copying it into each of

Which STL container should I use? C++

不问归期 提交于 2019-12-22 08:46:18
问题 I have a 'list' of objects, from which I want to take object at random position and push it on front of this list. Only this kind of operation will be performed. So I don't need a fast access to end of the list, only to it's front and average access to any other place. Which container would be the best for this? I was thinking about std::vector , but I've read that insert operation is not efficient. Then I came up with std::deque because of it's fast access to front, but what about efficiency

Refactoring a “dumb” function into generic STL-style with iterators to containers

孤人 提交于 2019-12-22 08:06:55
问题 I've managed to wrap my head around some of C++'s functional capacities (for_each, mapping functions, using iterators...) but the construction of the templates and function argument lists for taking in generic containers and iterators still eludes me. I have a practical example I'm hoping someone can illustrate for me: Take the following function that processes an incoming std::vector and builds a running total of many data-points/iterations of a process: /* the for-loop method - not very

What are the qualifications for a class in C++ to become a container?

Deadly 提交于 2019-12-22 04:45:34
问题 I'm new to C++ programming and came across the term containers with examples such as vector , deque , map , etc. What should be the minimum requirements that a class should fulfill to be called a container in C++? 回答1: I will start with the concept Range. Range has only two methods -- begin and end. They both return iterators of the same type (note: there are proposals to permit end to return a Sentinel instead). Iterators are presumed to be understood by the reader. A high quality Range can

Move `unique_ptr`s between sets

半城伤御伤魂 提交于 2019-12-22 04:42:12
问题 I have two sets and an iterator to an element of a : set<unique_ptr<X>> a, b; set<unique_ptr<X>>::iterator iter = find something in a; I would like to remove the element pointed by iter from a and insert it into b . Is it possible? How? 回答1: Well, I suspect there is no normal way to do it. But there is always a non-normal one :) You can do the following: auto tmp = const_cast<std::unique_ptr<std::string>&&>(*iter); a.erase(iter); b.insert(std::move(tmp)); Ok, the very first line violated set

Move `unique_ptr`s between sets

大城市里の小女人 提交于 2019-12-22 04:42:04
问题 I have two sets and an iterator to an element of a : set<unique_ptr<X>> a, b; set<unique_ptr<X>>::iterator iter = find something in a; I would like to remove the element pointed by iter from a and insert it into b . Is it possible? How? 回答1: Well, I suspect there is no normal way to do it. But there is always a non-normal one :) You can do the following: auto tmp = const_cast<std::unique_ptr<std::string>&&>(*iter); a.erase(iter); b.insert(std::move(tmp)); Ok, the very first line violated set

AWS Lambda Container destroy event

早过忘川 提交于 2019-12-22 01:39:28
问题 When to release connections and cleanup resources in lambda. In normal Node JS application we do use the hook process.on('exit', (code) => { console.log(`About to exit with code: ${code}`); }); However this doesn't work on AWS Lambda. Resulting the Mysql connection in sleep mode. We don't have enough resource for such active connections. None of the AWS documentation specify a way to achieve this. How to receive stop event of AWS Lambda container ? 回答1: EDIT: The short answer is that there is