在Std::to_string替换函数中无法识别Std::stringstream对象
std::stringstream object unrecognized in std::to_string replacement function
由于std::to_string不适合我,并且由于我目前正在一个非常困难的环境中工作(我正在使用Linux终端模拟器在Android上工作),我决定让它中断并使用用户自制的函数来代替它(我在网上找到了它)。
下面是我使用的确切代码:
#include <sstream>
namespace patch {
template <typename T>
std::string to_string(const T &n);
std::stringstream stm;
stm << n;
return stm.str();
}
}
我正在使用这些标签编译它:
g++ -std=c++11 -g -Wall -Wextra -pedantic
我得到这些错误:
unknown type name 'stm'; did you mean 'tm'?
stm << n;
^~~
(然后tm
在include/time.h
某处声明的注释)
expected unqualified-id
return stm.str();
^
最后一个大括号关闭了命名空间大括号,然后还有一个"多余的大括号"错误。
据我所知,它不将stm << n;
行识别为std::stringstream
对象上使用的方法operator <<
,而是出于某种原因将其视为某些变量声明。
为什么我得到这些错误?有办法解决吗?如果没有,我可以用什么来代替这个解决方案呢?
看起来你有一个分号,左花括号应该是打开函数范围
相关文章:
- std::visit无法识别类型
- 带有 CMake 的 Clang++-6.0 无法识别 std::string_view
- 如何识别容器中的 std::function 并将其删除?
- 为什么 std:cin 无法识别回车键
- std::regex总是可以识别区域设置吗?
- QVariant 转换无法识别我的模板调用的 std::string
- std::regex来识别多项式方程的系数
- 函数对象无法识别它获得的参数(std::set<int>)
- Android NDK和Crystax无法识别STD :: Index_Sequence
- G-WAN cc1plus:错误:无法识别的命令行选项"-std=gnu++0x"
- Boost.Spirit编译器无法识别std::p air
- 用加密的std :: string(未识别的令牌)查询SQLLITE查询
- Netbeans 7.2 中 c++ "-std=c++11"无法识别的命令行选项
- 在 std::set 中插入对不一致(无法识别 <pair>.second)
- std::strtoull在我的JNI NDK环境下无法识别
- Windows上的代码::块13.12即使使用-std=c++11也无法识别std::codecvt
- std::sort 无法识别迭代器类别
- CFLAGS=-std=c++11 -O3 -wall -pedantic在makefile中无法识别
- Scons 选择哪个版本的 g++ |无法识别的命令行选项"-std=c++11"
- Clang无法识别带有libstdc++的std::shared_ptr