namespaces

Forward declaring a function in a namespace inside another function in that namespace

喜夏-厌秋 提交于 2021-01-27 04:51:08
问题 I have two source files, a.cpp and b.cpp . In a.cpp , I have a function, foo : namespace ns { void foo() { std::cout << "foo!"; } } In b.cpp , I have another function in namespace ns in which I'd like to prototype and call foo : namespace ns { void bar() { void foo(); foo(); } } While the above is syntactically valid, it leads the compiler to think that foo is in the global namespace (or at least that's what I've deduced from the linker errors I get when I do this). My first two ideas to fix

ClojureScript split one namespace into multiple files

坚强是说给别人听的谎言 提交于 2021-01-27 04:43:51
问题 I've read this thread, but it seems like there are no load and load-file in ClojureScript. Is it possible to separate a single namespace over multiple files? The reason I want to do that is because I'm using Om and I want to separate components into different files. I can do it using separate namespaces, but then I will have to write the same requires in the beginning of each file and also the only way to call those components in the main file is like that: (:require [some-project.sidebar :as

Namespaces and generic functions in R

吃可爱长大的小学妹 提交于 2021-01-27 04:10:42
问题 this question is somewhat a follow up on this question. Consider the following example set.seed(1) x <- cumsum(rnorm(10)) y <- stats::arima(x, order = c(1, 0, 0)) length(stats::fitted(y)) [1] 0 So far so good: zero is returned because R does not now how to use stats::fitted on an object of class Arima . Next in my code, I need one function from the forecast package. I do not attach the package, I just load it using the :: notation. In my code below I will load it directly using

Why boost::bind insists pulling `boost::placeholders` into global namespace?

こ雲淡風輕ζ 提交于 2021-01-26 07:31:08
问题 The following code can be fixed easily, but quite annoying. #include <functional> #include <boost/bind.hpp> void foo() { using namespace std::placeholders; std::bind(_1, _2, _3); // ambiguous } There's a macro BOOST_BIND_NO_PLACEHOLDERS , but using this macro will also bring some drawbacks like causing boost::placeholders disappear from the compile unit included <boost/bind.hpp> but not included <boost/bind/placeholders.hpp> . The name conflicts also comes with other libs like boost::mpl , I

Why boost::bind insists pulling `boost::placeholders` into global namespace?

社会主义新天地 提交于 2021-01-26 07:30:25
问题 The following code can be fixed easily, but quite annoying. #include <functional> #include <boost/bind.hpp> void foo() { using namespace std::placeholders; std::bind(_1, _2, _3); // ambiguous } There's a macro BOOST_BIND_NO_PLACEHOLDERS , but using this macro will also bring some drawbacks like causing boost::placeholders disappear from the compile unit included <boost/bind.hpp> but not included <boost/bind/placeholders.hpp> . The name conflicts also comes with other libs like boost::mpl , I

How to namespace keys on redis to avoid name collisions?

こ雲淡風輕ζ 提交于 2021-01-21 08:46:22
问题 I want to use redis to store some of my own key-value pairs, however some of my modules already use it. The redis express session store for session data, as well as the redis adapter for socket io. So my question is simple, how can I create or designate a database/namespace to store my own keys without key collisions? I am using the node-redis driver. 回答1: Solution 1: Store data of different modules in different Redis instances The most strictly isolation is storing data of each module in an

How to replace namespace prefix in element and attributes using xslt

人盡茶涼 提交于 2021-01-20 07:13:57
问题 I have a source xml like following: <SampleRequest xmlns="http://sample.com/s" xmlns:s1="http://sample.com/s1" xmlns:s2="http://sample.com/s2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://sample.com/s schema.xsd"> <data> <s1:customer s1:firstName="Jim" s1:lastName="Ellison"/> <s2:address> 123 test street </s2:address> </data> </SampleRequest> I need to transform it to the following <SampleRequest xmlns="http://sample.com/t" xmlns:t1="http://sample.com/t1"

How to replace namespace prefix in element and attributes using xslt

放肆的年华 提交于 2021-01-20 07:13:35
问题 I have a source xml like following: <SampleRequest xmlns="http://sample.com/s" xmlns:s1="http://sample.com/s1" xmlns:s2="http://sample.com/s2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://sample.com/s schema.xsd"> <data> <s1:customer s1:firstName="Jim" s1:lastName="Ellison"/> <s2:address> 123 test street </s2:address> </data> </SampleRequest> I need to transform it to the following <SampleRequest xmlns="http://sample.com/t" xmlns:t1="http://sample.com/t1"

importing with * (asterisk) versus as a namespace in python

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-05 20:34:59
问题 I know that its bad form to use import * in python, and I don't plan to make a habit of it. However I recently came across some curious behaviour that I don't understand, and wondered if someone could explain it to me. Lets say I have three python scripts. The first, first_script.py , comprises: MESSAGE = 'this is from the first script' def print_message(): print MESSAGE if __name__ == '__main__': print_message() Obviously running this script gives me the contents of MESSAGE. I have a second

importing with * (asterisk) versus as a namespace in python

我是研究僧i 提交于 2021-01-05 20:31:53
问题 I know that its bad form to use import * in python, and I don't plan to make a habit of it. However I recently came across some curious behaviour that I don't understand, and wondered if someone could explain it to me. Lets say I have three python scripts. The first, first_script.py , comprises: MESSAGE = 'this is from the first script' def print_message(): print MESSAGE if __name__ == '__main__': print_message() Obviously running this script gives me the contents of MESSAGE. I have a second