Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
b56f4a4e
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b56f4a4e
编写于
2月 11, 2018
作者:
T
Tao Luo
提交者:
Yi Wang
2月 10, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move code from /paddle/string to /paddle/fluid/string (#8363)
上级
9029a9d9
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
61 addition
and
85 deletion
+61
-85
paddle/CMakeLists.txt
paddle/CMakeLists.txt
+0
-1
paddle/fluid/CMakeLists.txt
paddle/fluid/CMakeLists.txt
+1
-0
paddle/fluid/framework/init.cc
paddle/fluid/framework/init.cc
+1
-1
paddle/fluid/framework/scope.cc
paddle/fluid/framework/scope.cc
+1
-1
paddle/fluid/operators/listen_and_serv_op.cc
paddle/fluid/operators/listen_and_serv_op.cc
+1
-1
paddle/fluid/operators/send_recv_op_test.cc
paddle/fluid/operators/send_recv_op_test.cc
+1
-1
paddle/fluid/platform/cpu_info_test.cc
paddle/fluid/platform/cpu_info_test.cc
+1
-1
paddle/fluid/platform/enforce.h
paddle/fluid/platform/enforce.h
+2
-2
paddle/fluid/platform/enforce_test.cc
paddle/fluid/platform/enforce_test.cc
+1
-1
paddle/fluid/pybind/pybind.cc
paddle/fluid/pybind/pybind.cc
+1
-1
paddle/fluid/string/.clang-format
paddle/fluid/string/.clang-format
+0
-0
paddle/fluid/string/CMakeLists.txt
paddle/fluid/string/CMakeLists.txt
+0
-0
paddle/fluid/string/piece.cc
paddle/fluid/string/piece.cc
+1
-1
paddle/fluid/string/piece.h
paddle/fluid/string/piece.h
+2
-2
paddle/fluid/string/piece_test.cc
paddle/fluid/string/piece_test.cc
+1
-1
paddle/fluid/string/printf.h
paddle/fluid/string/printf.h
+1
-1
paddle/fluid/string/printf_test.cc
paddle/fluid/string/printf_test.cc
+3
-3
paddle/fluid/string/tinyformat/tinyformat.h
paddle/fluid/string/tinyformat/tinyformat.h
+41
-65
paddle/fluid/string/to_string.h
paddle/fluid/string/to_string.h
+0
-0
paddle/fluid/string/to_string_test.cc
paddle/fluid/string/to_string_test.cc
+2
-2
未找到文件。
paddle/CMakeLists.txt
浏览文件 @
b56f4a4e
...
@@ -11,7 +11,6 @@ if(MOBILE_INFERENCE)
...
@@ -11,7 +11,6 @@ if(MOBILE_INFERENCE)
else
()
else
()
add_subdirectory
(
pserver
)
add_subdirectory
(
pserver
)
add_subdirectory
(
trainer
)
add_subdirectory
(
trainer
)
add_subdirectory
(
string
)
add_subdirectory
(
scripts
)
add_subdirectory
(
scripts
)
if
(
WITH_C_API
)
if
(
WITH_C_API
)
...
...
paddle/fluid/CMakeLists.txt
浏览文件 @
b56f4a4e
...
@@ -4,3 +4,4 @@ add_subdirectory(framework)
...
@@ -4,3 +4,4 @@ add_subdirectory(framework)
add_subdirectory
(
operators
)
add_subdirectory
(
operators
)
add_subdirectory
(
pybind
)
add_subdirectory
(
pybind
)
add_subdirectory
(
inference
)
add_subdirectory
(
inference
)
add_subdirectory
(
string
)
paddle/fluid/framework/init.cc
浏览文件 @
b56f4a4e
...
@@ -20,7 +20,7 @@ limitations under the License. */
...
@@ -20,7 +20,7 @@ limitations under the License. */
#include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/place.h"
#include "paddle/fluid/platform/place.h"
#include "paddle/string/piece.h"
#include "paddle/
fluid/
string/piece.h"
namespace
paddle
{
namespace
paddle
{
namespace
framework
{
namespace
framework
{
...
...
paddle/fluid/framework/scope.cc
浏览文件 @
b56f4a4e
...
@@ -18,7 +18,7 @@ limitations under the License. */
...
@@ -18,7 +18,7 @@ limitations under the License. */
#include <mutex> // for call_once
#include <mutex> // for call_once
#include "glog/logging.h"
#include "glog/logging.h"
#include "paddle/fluid/framework/threadpool.h"
#include "paddle/fluid/framework/threadpool.h"
#include "paddle/string/printf.h"
#include "paddle/
fluid/
string/printf.h"
DEFINE_bool
(
benchmark
,
false
,
DEFINE_bool
(
benchmark
,
false
,
"Doing memory benchmark. It will make deleting scope synchronized, "
"Doing memory benchmark. It will make deleting scope synchronized, "
...
...
paddle/fluid/operators/listen_and_serv_op.cc
浏览文件 @
b56f4a4e
...
@@ -27,7 +27,7 @@ limitations under the License. */
...
@@ -27,7 +27,7 @@ limitations under the License. */
#include "paddle/fluid/operators/detail/grpc_server.h"
#include "paddle/fluid/operators/detail/grpc_server.h"
#include "paddle/fluid/operators/detail/sendrecvop_utils.h"
#include "paddle/fluid/operators/detail/sendrecvop_utils.h"
#include "paddle/fluid/operators/detail/simple_block_queue.h"
#include "paddle/fluid/operators/detail/simple_block_queue.h"
#include "paddle/string/printf.h"
#include "paddle/
fluid/
string/printf.h"
namespace
paddle
{
namespace
paddle
{
namespace
operators
{
namespace
operators
{
...
...
paddle/fluid/operators/send_recv_op_test.cc
浏览文件 @
b56f4a4e
...
@@ -22,7 +22,7 @@ limitations under the License. */
...
@@ -22,7 +22,7 @@ limitations under the License. */
#include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/operators/math/math_function.h"
#include "paddle/fluid/operators/math/selected_rows_functor.h"
#include "paddle/fluid/operators/math/selected_rows_functor.h"
#include "paddle/string/printf.h"
#include "paddle/
fluid/
string/printf.h"
USE_NO_KERNEL_OP
(
send
);
USE_NO_KERNEL_OP
(
send
);
USE_NO_KERNEL_OP
(
listen_and_serv
);
USE_NO_KERNEL_OP
(
listen_and_serv
);
...
...
paddle/fluid/platform/cpu_info_test.cc
浏览文件 @
b56f4a4e
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// See the License for the specific language governing permissions and
// limitations under the License.
// limitations under the License.
#include "paddle/fluid/platform/cpu_info.h"
#include "paddle/fluid/platform/cpu_info.h"
#include "paddle/string/printf.h"
#include "paddle/
fluid/
string/printf.h"
#include <ostream>
#include <ostream>
#include <sstream>
#include <sstream>
...
...
paddle/fluid/platform/enforce.h
浏览文件 @
b56f4a4e
...
@@ -23,8 +23,8 @@ limitations under the License. */
...
@@ -23,8 +23,8 @@ limitations under the License. */
#include <string>
#include <string>
#include "paddle/fluid/platform/macros.h"
#include "paddle/fluid/platform/macros.h"
#include "paddle/string/printf.h"
#include "paddle/
fluid/
string/printf.h"
#include "paddle/string/to_string.h"
#include "paddle/
fluid/
string/to_string.h"
#ifdef __GNUC__
#ifdef __GNUC__
#include <cxxabi.h> // for __cxa_demangle
#include <cxxabi.h> // for __cxa_demangle
...
...
paddle/fluid/platform/enforce_test.cc
浏览文件 @
b56f4a4e
...
@@ -15,7 +15,7 @@ limitations under the License. */
...
@@ -15,7 +15,7 @@ limitations under the License. */
#include "gtest/gtest.h"
#include "gtest/gtest.h"
#include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/enforce.h"
#include "paddle/string/piece.h"
#include "paddle/
fluid/
string/piece.h"
using
StringPiece
=
paddle
::
string
::
Piece
;
using
StringPiece
=
paddle
::
string
::
Piece
;
using
paddle
::
string
::
HasPrefix
;
using
paddle
::
string
::
HasPrefix
;
...
...
paddle/fluid/pybind/pybind.cc
浏览文件 @
b56f4a4e
...
@@ -35,7 +35,7 @@ limitations under the License. */
...
@@ -35,7 +35,7 @@ limitations under the License. */
#include "paddle/fluid/pybind/exception.h"
#include "paddle/fluid/pybind/exception.h"
#include "paddle/fluid/pybind/pybind.h"
#include "paddle/fluid/pybind/pybind.h"
#include "paddle/fluid/pybind/tensor_py.h"
#include "paddle/fluid/pybind/tensor_py.h"
#include "paddle/string/to_string.h"
#include "paddle/
fluid/
string/to_string.h"
#ifdef PADDLE_WITH_CUDA
#ifdef PADDLE_WITH_CUDA
#include "paddle/fluid/operators/nccl/nccl_gpu_common.h"
#include "paddle/fluid/operators/nccl/nccl_gpu_common.h"
...
...
paddle/string/.clang-format
→
paddle/
fluid/
string/.clang-format
浏览文件 @
b56f4a4e
文件已移动
paddle/string/CMakeLists.txt
→
paddle/
fluid/
string/CMakeLists.txt
浏览文件 @
b56f4a4e
文件已移动
paddle/string/piece.cc
→
paddle/
fluid/
string/piece.cc
浏览文件 @
b56f4a4e
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// See the License for the specific language governing permissions and
// limitations under the License.
// limitations under the License.
#include "p
addle/string/p
iece.h"
#include "piece.h"
#include <string.h>
#include <string.h>
...
...
paddle/string/piece.h
→
paddle/
fluid/
string/piece.h
浏览文件 @
b56f4a4e
...
@@ -28,7 +28,7 @@ namespace string {
...
@@ -28,7 +28,7 @@ namespace string {
// its syntax is simple as it doesn't own/manage the string, it is
// its syntax is simple as it doesn't own/manage the string, it is
// cheap to construct Pieces and pass them around.
// cheap to construct Pieces and pass them around.
class
Piece
{
class
Piece
{
public:
public:
static
const
size_t
npos
=
static_cast
<
size_t
>
(
-
1
);
static
const
size_t
npos
=
static_cast
<
size_t
>
(
-
1
);
// We provide non-explicit singleton constructors so users can
// We provide non-explicit singleton constructors so users can
...
@@ -55,7 +55,7 @@ public:
...
@@ -55,7 +55,7 @@ public:
// Return a string that contains the copy of the referenced data.
// Return a string that contains the copy of the referenced data.
std
::
string
ToString
()
const
{
return
std
::
string
(
data_
,
size_
);
}
std
::
string
ToString
()
const
{
return
std
::
string
(
data_
,
size_
);
}
private:
private:
const
char
*
data_
;
const
char
*
data_
;
size_t
size_
;
size_t
size_
;
...
...
paddle/string/piece_test.cc
→
paddle/
fluid/
string/piece_test.cc
浏览文件 @
b56f4a4e
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// See the License for the specific language governing permissions and
// limitations under the License.
// limitations under the License.
#include "paddle/string/piece.h"
#include "paddle/
fluid/
string/piece.h"
#include <sstream>
#include <sstream>
...
...
paddle/string/printf.h
→
paddle/
fluid/
string/printf.h
浏览文件 @
b56f4a4e
...
@@ -71,7 +71,7 @@
...
@@ -71,7 +71,7 @@
#include <iostream>
#include <iostream>
#include <sstream>
#include <sstream>
#include "
paddle/string/
tinyformat/tinyformat.h" // https://github.com/c42f/tinyformat
#include "tinyformat/tinyformat.h" // https://github.com/c42f/tinyformat
namespace
paddle
{
namespace
paddle
{
namespace
string
{
namespace
string
{
...
...
paddle/string/printf_test.cc
→
paddle/
fluid/
string/printf_test.cc
浏览文件 @
b56f4a4e
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// See the License for the specific language governing permissions and
// limitations under the License.
// limitations under the License.
#include "p
addle/string/p
rintf.h"
#include "printf.h"
#include <string>
#include <string>
...
@@ -24,6 +24,6 @@ TEST(StringPrintf, StringPrintf) {
...
@@ -24,6 +24,6 @@ TEST(StringPrintf, StringPrintf) {
long
hour
=
14
;
long
hour
=
14
;
int
min
=
44
;
int
min
=
44
;
EXPECT_EQ
(
std
::
string
(
"Wednesday, July 27, 14:44"
),
EXPECT_EQ
(
std
::
string
(
"Wednesday, July 27, 14:44"
),
paddle
::
string
::
Sprintf
(
paddle
::
string
::
Sprintf
(
"%s, %s %d, %.2d:%.2d"
,
weekday
,
month
,
day
,
"%s, %s %d, %.2d:%.2d"
,
weekday
,
month
,
day
,
hour
,
min
));
hour
,
min
));
}
}
paddle/string/tinyformat/tinyformat.h
→
paddle/
fluid/
string/tinyformat/tinyformat.h
浏览文件 @
b56f4a4e
...
@@ -147,7 +147,7 @@ namespace detail {
...
@@ -147,7 +147,7 @@ namespace detail {
// Test whether type T1 is convertible to type T2
// Test whether type T1 is convertible to type T2
template
<
typename
T1
,
typename
T2
>
template
<
typename
T1
,
typename
T2
>
struct
is_convertible
{
struct
is_convertible
{
private:
private:
// two types of different size
// two types of different size
struct
fail
{
struct
fail
{
char
dummy
[
2
];
char
dummy
[
2
];
...
@@ -160,7 +160,7 @@ private:
...
@@ -160,7 +160,7 @@ private:
static
succeed
tryConvert
(
const
T2
&
);
static
succeed
tryConvert
(
const
T2
&
);
static
const
T1
&
makeT1
();
static
const
T1
&
makeT1
();
public:
public:
// Standard trick: the (...) version of tryConvert will be chosen from
// Standard trick: the (...) version of tryConvert will be chosen from
// the overload set only if the version taking a T2 doesn't match.
// the overload set only if the version taking a T2 doesn't match.
// Then we compare the sizes of the return types to check which
// Then we compare the sizes of the return types to check which
...
@@ -170,8 +170,7 @@ public:
...
@@ -170,8 +170,7 @@ public:
// Format the value by casting to type fmtT. This default implementation
// Format the value by casting to type fmtT. This default implementation
// should never be called.
// should never be called.
template
<
typename
T
,
template
<
typename
T
,
typename
fmtT
,
typename
fmtT
,
bool
convertible
=
is_convertible
<
T
,
fmtT
>
::
value
>
bool
convertible
=
is_convertible
<
T
,
fmtT
>
::
value
>
struct
formatValueAsType
{
struct
formatValueAsType
{
static
void
invoke
(
std
::
ostream
&
/*out*/
,
const
T
&
/*value*/
)
{
assert
(
0
);
}
static
void
invoke
(
std
::
ostream
&
/*out*/
,
const
T
&
/*value*/
)
{
assert
(
0
);
}
...
@@ -241,11 +240,8 @@ TINYFORMAT_DEFINE_FORMAT_TRUNCATED_CSTR(char)
...
@@ -241,11 +240,8 @@ TINYFORMAT_DEFINE_FORMAT_TRUNCATED_CSTR(char)
/// operator<< to format the type T, with special cases for the %c and %p
/// operator<< to format the type T, with special cases for the %c and %p
/// conversions.
/// conversions.
template
<
typename
T
>
template
<
typename
T
>
inline
void
formatValue
(
std
::
ostream
&
out
,
inline
void
formatValue
(
std
::
ostream
&
out
,
const
char
*
/*fmtBegin*/
,
const
char
*
/*fmtBegin*/
,
const
char
*
fmtEnd
,
int
ntrunc
,
const
T
&
value
)
{
const
char
*
fmtEnd
,
int
ntrunc
,
const
T
&
value
)
{
// The mess here is to support the %c and %p conversions: if these
// The mess here is to support the %c and %p conversions: if these
// conversions are active we try to convert the type to a char or const
// conversions are active we try to convert the type to a char or const
// void* respectively and format that instead of the value itself. For the
// void* respectively and format that instead of the value itself. For the
...
@@ -267,25 +263,22 @@ inline void formatValue(std::ostream &out,
...
@@ -267,25 +263,22 @@ inline void formatValue(std::ostream &out,
}
}
// Overloaded version for char types to support printing as an integer
// Overloaded version for char types to support printing as an integer
#define TINYFORMAT_DEFINE_FORMATVALUE_CHAR(charType) \
#define TINYFORMAT_DEFINE_FORMATVALUE_CHAR(charType) \
inline void formatValue(std::ostream &out, \
inline void formatValue(std::ostream &out, const char *
/*fmtBegin*/
, \
const char *
/*fmtBegin*/
, \
const char *fmtEnd, int
/**/
, charType value) { \
const char *fmtEnd, \
switch (*(fmtEnd - 1)) { \
int
/**/
, \
case 'u': \
charType value) { \
case 'd': \
switch (*(fmtEnd - 1)) { \
case 'i': \
case 'u': \
case 'o': \
case 'd': \
case 'X': \
case 'i': \
case 'x': \
case 'o': \
out << static_cast<int>(value); \
case 'X': \
break; \
case 'x': \
default: \
out << static_cast<int>(value); \
out << value; \
break; \
break; \
default: \
} \
out << value; \
break; \
} \
}
}
// per 3.9.1: char, signed char and unsigned char are all distinct types
// per 3.9.1: char, signed char and unsigned char are all distinct types
TINYFORMAT_DEFINE_FORMATVALUE_CHAR
(
char
)
TINYFORMAT_DEFINE_FORMATVALUE_CHAR
(
char
)
...
@@ -482,7 +475,7 @@ namespace detail {
...
@@ -482,7 +475,7 @@ namespace detail {
// each argument to be allocated as a homogenous array inside FormatList
// each argument to be allocated as a homogenous array inside FormatList
// whereas a naive implementation based on inheritance does not.
// whereas a naive implementation based on inheritance does not.
class
FormatArg
{
class
FormatArg
{
public:
public:
FormatArg
()
{}
FormatArg
()
{}
template
<
typename
T
>
template
<
typename
T
>
...
@@ -491,22 +484,17 @@ public:
...
@@ -491,22 +484,17 @@ public:
m_formatImpl
(
&
formatImpl
<
T
>
),
m_formatImpl
(
&
formatImpl
<
T
>
),
m_toIntImpl
(
&
toIntImpl
<
T
>
)
{}
m_toIntImpl
(
&
toIntImpl
<
T
>
)
{}
void
format
(
std
::
ostream
&
out
,
void
format
(
std
::
ostream
&
out
,
const
char
*
fmtBegin
,
const
char
*
fmtEnd
,
const
char
*
fmtBegin
,
const
char
*
fmtEnd
,
int
ntrunc
)
const
{
int
ntrunc
)
const
{
m_formatImpl
(
out
,
fmtBegin
,
fmtEnd
,
ntrunc
,
m_value
);
m_formatImpl
(
out
,
fmtBegin
,
fmtEnd
,
ntrunc
,
m_value
);
}
}
int
toInt
()
const
{
return
m_toIntImpl
(
m_value
);
}
int
toInt
()
const
{
return
m_toIntImpl
(
m_value
);
}
private:
private:
template
<
typename
T
>
template
<
typename
T
>
static
void
formatImpl
(
std
::
ostream
&
out
,
static
void
formatImpl
(
std
::
ostream
&
out
,
const
char
*
fmtBegin
,
const
char
*
fmtBegin
,
const
char
*
fmtEnd
,
int
ntrunc
,
const
void
*
value
)
{
const
char
*
fmtEnd
,
int
ntrunc
,
const
void
*
value
)
{
formatValue
(
out
,
fmtBegin
,
fmtEnd
,
ntrunc
,
*
static_cast
<
const
T
*>
(
value
));
formatValue
(
out
,
fmtBegin
,
fmtEnd
,
ntrunc
,
*
static_cast
<
const
T
*>
(
value
));
}
}
...
@@ -516,11 +504,8 @@ private:
...
@@ -516,11 +504,8 @@ private:
}
}
const
void
*
m_value
;
const
void
*
m_value
;
void
(
*
m_formatImpl
)(
std
::
ostream
&
out
,
void
(
*
m_formatImpl
)(
std
::
ostream
&
out
,
const
char
*
fmtBegin
,
const
char
*
fmtBegin
,
const
char
*
fmtEnd
,
int
ntrunc
,
const
void
*
value
);
const
char
*
fmtEnd
,
int
ntrunc
,
const
void
*
value
);
int
(
*
m_toIntImpl
)(
const
void
*
value
);
int
(
*
m_toIntImpl
)(
const
void
*
value
);
};
};
...
@@ -569,12 +554,10 @@ inline const char *printFormatStringLiteral(std::ostream &out,
...
@@ -569,12 +554,10 @@ inline const char *printFormatStringLiteral(std::ostream &out,
// necessary to pull out variable width and precision . The function returns a
// necessary to pull out variable width and precision . The function returns a
// pointer to the character after the end of the current format spec.
// pointer to the character after the end of the current format spec.
inline
const
char
*
streamStateFromFormat
(
std
::
ostream
&
out
,
inline
const
char
*
streamStateFromFormat
(
std
::
ostream
&
out
,
bool
&
spacePadPositive
,
bool
&
spacePadPositive
,
int
&
ntrunc
,
int
&
ntrunc
,
const
char
*
fmtStart
,
const
char
*
fmtStart
,
const
detail
::
FormatArg
*
formatters
,
const
detail
::
FormatArg
*
formatters
,
int
&
argIndex
,
int
&
argIndex
,
int
numFormatters
)
{
int
numFormatters
)
{
if
(
*
fmtStart
!=
'%'
)
{
if
(
*
fmtStart
!=
'%'
)
{
TINYFORMAT_ERROR
(
TINYFORMAT_ERROR
(
"tinyformat: Not enough conversion specifiers in format string"
);
"tinyformat: Not enough conversion specifiers in format string"
);
...
@@ -750,10 +733,8 @@ inline const char *streamStateFromFormat(std::ostream &out,
...
@@ -750,10 +733,8 @@ inline const char *streamStateFromFormat(std::ostream &out,
}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
inline
void
formatImpl
(
std
::
ostream
&
out
,
inline
void
formatImpl
(
std
::
ostream
&
out
,
const
char
*
fmt
,
const
char
*
fmt
,
const
detail
::
FormatArg
*
formatters
,
int
numFormatters
)
{
const
detail
::
FormatArg
*
formatters
,
int
numFormatters
)
{
// Saved stream state
// Saved stream state
std
::
streamsize
origWidth
=
out
.
width
();
std
::
streamsize
origWidth
=
out
.
width
();
std
::
streamsize
origPrecision
=
out
.
precision
();
std
::
streamsize
origPrecision
=
out
.
precision
();
...
@@ -765,13 +746,9 @@ inline void formatImpl(std::ostream &out,
...
@@ -765,13 +746,9 @@ inline void formatImpl(std::ostream &out,
fmt
=
printFormatStringLiteral
(
out
,
fmt
);
fmt
=
printFormatStringLiteral
(
out
,
fmt
);
bool
spacePadPositive
=
false
;
bool
spacePadPositive
=
false
;
int
ntrunc
=
-
1
;
int
ntrunc
=
-
1
;
const
char
*
fmtEnd
=
streamStateFromFormat
(
out
,
const
char
*
fmtEnd
=
spacePadPositive
,
streamStateFromFormat
(
out
,
spacePadPositive
,
ntrunc
,
fmt
,
formatters
,
ntrunc
,
argIndex
,
numFormatters
);
fmt
,
formatters
,
argIndex
,
numFormatters
);
if
(
argIndex
>=
numFormatters
)
{
if
(
argIndex
>=
numFormatters
)
{
// Check args remain after reading any variable width/precision
// Check args remain after reading any variable width/precision
TINYFORMAT_ERROR
(
"tinyformat: Not enough format arguments"
);
TINYFORMAT_ERROR
(
"tinyformat: Not enough format arguments"
);
...
@@ -820,15 +797,14 @@ inline void formatImpl(std::ostream &out,
...
@@ -820,15 +797,14 @@ inline void formatImpl(std::ostream &out,
/// information has been stripped from the arguments, leaving just enough of a
/// information has been stripped from the arguments, leaving just enough of a
/// common interface to perform formatting as required.
/// common interface to perform formatting as required.
class
FormatList
{
class
FormatList
{
public:
public:
FormatList
(
detail
::
FormatArg
*
formatters
,
int
N
)
FormatList
(
detail
::
FormatArg
*
formatters
,
int
N
)
:
m_formatters
(
formatters
),
m_N
(
N
)
{}
:
m_formatters
(
formatters
),
m_N
(
N
)
{}
friend
void
vformat
(
std
::
ostream
&
out
,
friend
void
vformat
(
std
::
ostream
&
out
,
const
char
*
fmt
,
const
char
*
fmt
,
const
FormatList
&
list
);
const
FormatList
&
list
);
private:
private:
const
detail
::
FormatArg
*
m_formatters
;
const
detail
::
FormatArg
*
m_formatters
;
int
m_N
;
int
m_N
;
};
};
...
@@ -841,7 +817,7 @@ namespace detail {
...
@@ -841,7 +817,7 @@ namespace detail {
// Format list subclass with fixed storage to avoid dynamic allocation
// Format list subclass with fixed storage to avoid dynamic allocation
template
<
int
N
>
template
<
int
N
>
class
FormatListN
:
public
FormatList
{
class
FormatListN
:
public
FormatList
{
public:
public:
template
<
typename
...
Args
>
template
<
typename
...
Args
>
FormatListN
(
const
Args
&
...
args
)
FormatListN
(
const
Args
&
...
args
)
:
FormatList
(
&
m_formatterStore
[
0
],
N
),
:
FormatList
(
&
m_formatterStore
[
0
],
N
),
...
@@ -849,14 +825,14 @@ public:
...
@@ -849,14 +825,14 @@ public:
static_assert
(
sizeof
...(
args
)
==
N
,
"Number of args must be N"
);
static_assert
(
sizeof
...(
args
)
==
N
,
"Number of args must be N"
);
}
}
private:
private:
FormatArg
m_formatterStore
[
N
];
FormatArg
m_formatterStore
[
N
];
};
};
// Special 0-arg version - MSVC says zero-sized C array in struct is nonstandard
// Special 0-arg version - MSVC says zero-sized C array in struct is nonstandard
template
<
>
template
<
>
class
FormatListN
<
0
>
:
public
FormatList
{
class
FormatListN
<
0
>
:
public
FormatList
{
public:
public:
FormatListN
()
:
FormatList
(
0
,
0
)
{}
FormatListN
()
:
FormatList
(
0
,
0
)
{}
};
};
...
...
paddle/string/to_string.h
→
paddle/
fluid/
string/to_string.h
浏览文件 @
b56f4a4e
文件已移动
paddle/string/to_string_test.cc
→
paddle/
fluid/
string/to_string_test.cc
浏览文件 @
b56f4a4e
...
@@ -12,12 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -12,12 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include "
paddle/string/
to_string.h"
#include "to_string.h"
#include <gtest/gtest.h>
#include <gtest/gtest.h>
constexpr
char
kOutputString
[]
=
"User Defined Output"
;
constexpr
char
kOutputString
[]
=
"User Defined Output"
;
class
UserDefinedClass
{
class
UserDefinedClass
{
public:
public:
};
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
s
,
const
UserDefinedClass
&
ins
)
{
std
::
ostream
&
operator
<<
(
std
::
ostream
&
s
,
const
UserDefinedClass
&
ins
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录